diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 4fcd94fe4a..0c7473f708 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -1628,7 +1628,7 @@ public final class FilePath implements Serializable { IOUtils.copy(t,f); f.setLastModified(te.getModTime().getTime()); int mode = te.getMode()&0777; - if(mode!=0 && !Hudson.isWindows()) // be defensive + if(mode!=0 && !Functions.isWindows()) // be defensive try { LIBC.chmod(f.getPath(),mode); } catch (NoClassDefFoundError e) { diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index bf397369ee..22709ef550 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -963,7 +963,7 @@ public class Util { * If there's a prior symlink at baseDir+symlinkPath, it will be overwritten. */ public static void createSymlink(File baseDir, String targetPath, String symlinkPath, TaskListener listener) throws InterruptedException { - if(isWindows() || NO_SYMLINK) return; + if(Functions.isWindows() || NO_SYMLINK) return; try { // if a file or a directory exists here, delete it first. @@ -1009,7 +1009,7 @@ public class Util { * (TODO: try readlink(1) available on some platforms) */ public static String resolveSymlink(File link, TaskListener listener) throws InterruptedException, IOException { - if(isWindows()) return null; + if(Functions.isWindows()) return null; String filename = link.getAbsolutePath(); try { diff --git a/core/src/main/java/hudson/lifecycle/Lifecycle.java b/core/src/main/java/hudson/lifecycle/Lifecycle.java index 54522e4d46..5bd4b9ef4c 100644 --- a/core/src/main/java/hudson/lifecycle/Lifecycle.java +++ b/core/src/main/java/hudson/lifecycle/Lifecycle.java @@ -24,6 +24,7 @@ package hudson.lifecycle; import hudson.ExtensionPoint; +import hudson.Functions; import hudson.Util; import hudson.model.Hudson; @@ -75,7 +76,7 @@ public abstract class Lifecycle implements ExtensionPoint { throw x; } } else { - if(Hudson.isWindows()) { + if(Functions.isWindows()) { instance = new Lifecycle() { @Override public void verifyRestartable() throws RestartNotSupportedException { diff --git a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java index ad7d05fbb7..45384fc5fb 100644 --- a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java +++ b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java @@ -23,10 +23,10 @@ */ package hudson.lifecycle; +import hudson.Functions; import hudson.model.ManagementLink; import hudson.model.Hudson; import hudson.AbortException; -import hudson.FilePath; import hudson.Extension; import hudson.util.StreamTaskListener; import hudson.util.jna.DotNet; @@ -241,7 +241,7 @@ public class WindowsInstallerLink extends ManagementLink { */ @Extension public static WindowsInstallerLink registerIfApplicable() { - if(!Hudson.isWindows()) + if(!Functions.isWindows()) return null; // this is a Windows only feature if(Lifecycle.get() instanceof WindowsServiceLifecycle) diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index 9173b8eeac..400e0fc5d8 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -3288,10 +3288,14 @@ public final class Hudson extends Node implements ItemGroup, Stapl return !"ISO-8859-1".equalsIgnoreCase(System.getProperty("file.encoding")); } + /** + * @deprecated + * Use {@link Functions#isWindows()}. + */ public static boolean isWindows() { return File.pathSeparatorChar==';'; } - + public static boolean isDarwin() { // according to http://developer.apple.com/technotes/tn2002/tn2110.html return System.getProperty("os.name").toLowerCase(Locale.ENGLISH).startsWith("mac"); diff --git a/core/src/main/java/hudson/security/PAMSecurityRealm.java b/core/src/main/java/hudson/security/PAMSecurityRealm.java index a947804a76..4022b35f6b 100644 --- a/core/src/main/java/hudson/security/PAMSecurityRealm.java +++ b/core/src/main/java/hudson/security/PAMSecurityRealm.java @@ -24,6 +24,7 @@ package hudson.security; import groovy.lang.Binding; +import hudson.Functions; import hudson.model.Descriptor; import hudson.model.Hudson; import hudson.Util; @@ -170,7 +171,7 @@ public class PAMSecurityRealm extends SecurityRealm { @Extension public static DescriptorImpl install() { - if(!Hudson.isWindows()) return new DescriptorImpl(); + if(!Functions.isWindows()) return new DescriptorImpl(); return null; } } diff --git a/core/src/main/java/hudson/tasks/Ant.java b/core/src/main/java/hudson/tasks/Ant.java index 2ddd993526..94ed14189d 100644 --- a/core/src/main/java/hudson/tasks/Ant.java +++ b/core/src/main/java/hudson/tasks/Ant.java @@ -27,6 +27,7 @@ import hudson.CopyOnWrite; import hudson.EnvVars; import hudson.Extension; import hudson.FilePath; +import hudson.Functions; import hudson.Launcher; import hudson.Util; import hudson.model.*; @@ -358,7 +359,7 @@ public class Ant extends Builder { private File getExeFile() { String execName; - if(Hudson.isWindows()) + if(Functions.isWindows()) execName = "ant.bat"; else execName = "ant"; diff --git a/core/src/main/java/hudson/tasks/Shell.java b/core/src/main/java/hudson/tasks/Shell.java index 66780e5b73..e4502e7abc 100644 --- a/core/src/main/java/hudson/tasks/Shell.java +++ b/core/src/main/java/hudson/tasks/Shell.java @@ -24,6 +24,7 @@ package hudson.tasks; import hudson.FilePath; +import hudson.Functions; import hudson.Util; import hudson.Extension; import hudson.model.AbstractProject; @@ -138,7 +139,7 @@ public class Shell extends CommandInterpreter { public String getShellOrDefault() { if(shell==null) - return isWindows()?"sh":"/bin/sh"; + return Functions.isWindows() ?"sh":"/bin/sh"; return shell; } diff --git a/core/src/main/java/hudson/tools/ZipExtractionInstaller.java b/core/src/main/java/hudson/tools/ZipExtractionInstaller.java index c00ec3ffac..1213773b8c 100644 --- a/core/src/main/java/hudson/tools/ZipExtractionInstaller.java +++ b/core/src/main/java/hudson/tools/ZipExtractionInstaller.java @@ -33,7 +33,6 @@ import hudson.Functions; import hudson.os.PosixAPI; import hudson.model.Node; import hudson.model.TaskListener; -import hudson.model.Hudson; import hudson.remoting.VirtualChannel; import hudson.util.FormValidation; import hudson.util.jna.GNUCLibrary; @@ -123,7 +122,7 @@ public class ZipExtractionInstaller extends ToolInstaller { static class ChmodRecAPlusX implements FileCallable { private static final long serialVersionUID = 1L; public Void invoke(File d, VirtualChannel channel) throws IOException { - if(!Hudson.isWindows()) + if(!Functions.isWindows()) process(d); return null; } diff --git a/core/src/test/java/hudson/UtilTest.java b/core/src/test/java/hudson/UtilTest.java index 9e7546c782..07dc35b228 100644 --- a/core/src/test/java/hudson/UtilTest.java +++ b/core/src/test/java/hudson/UtilTest.java @@ -30,7 +30,6 @@ import java.util.HashMap; import java.util.Locale; import java.io.File; -import hudson.model.Hudson; import hudson.util.StreamTaskListener; /** @@ -144,7 +143,7 @@ public class UtilTest extends TestCase { } public void testSymlink() throws Exception { - if (Hudson.isWindows()) return; + if (Functions.isWindows()) return; StreamTaskListener l = new StreamTaskListener(System.out); File d = Util.createTempDir(); diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index 2c43164a7e..8e5c16f874 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -57,7 +57,6 @@ import hudson.model.Result; import hudson.model.Run; import hudson.model.Saveable; import hudson.model.TaskListener; -import hudson.model.UpdateCenter; import hudson.model.UpdateSite; import hudson.model.AbstractProject; import hudson.model.View; @@ -147,9 +146,6 @@ import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.WebRequestSettings; import com.gargoylesoftware.htmlunit.xml.XmlPage; import com.gargoylesoftware.htmlunit.html.*; -import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine; -import com.gargoylesoftware.htmlunit.javascript.host.Stylesheet; -import hudson.model.Computer; import hudson.slaves.ComputerListener; import java.util.concurrent.CountDownLatch; @@ -435,7 +431,7 @@ public abstract class HudsonTestCase extends TestCase implements RootAction { File mvnHome = createTmpDir(); mvn.unzip(new FilePath(mvnHome)); // TODO: switch to tar that preserves file permissions more easily - if(!Hudson.isWindows()) + if(!Functions.isWindows()) GNUCLibrary.LIBC.chmod(new File(mvnHome,mavenVersion+"/bin/mvn").getPath(),0755); MavenInstallation mavenInstallation = new MavenInstallation("default", @@ -459,7 +455,7 @@ public abstract class HudsonTestCase extends TestCase implements RootAction { File antHome = createTmpDir(); ant.unzip(new FilePath(antHome)); // TODO: switch to tar that preserves file permissions more easily - if(!Hudson.isWindows()) + if(!Functions.isWindows()) GNUCLibrary.LIBC.chmod(new File(antHome,"apache-ant-1.7.1/bin/ant").getPath(),0755); antInstallation = new AntInstallation("default", new File(antHome,"apache-ant-1.7.1").getAbsolutePath(),NO_PROPERTIES); diff --git a/test/src/test/java/hudson/model/DirectoryBrowserSupportTest.java b/test/src/test/java/hudson/model/DirectoryBrowserSupportTest.java index 773dd7ddde..bd65a8322c 100644 --- a/test/src/test/java/hudson/model/DirectoryBrowserSupportTest.java +++ b/test/src/test/java/hudson/model/DirectoryBrowserSupportTest.java @@ -23,6 +23,7 @@ */ package hudson.model; +import hudson.Functions; import hudson.tasks.Shell; import hudson.tasks.BatchFile; import hudson.Launcher; @@ -43,7 +44,7 @@ public class DirectoryBrowserSupportTest extends HudsonTestCase { public void testDoubleDots() throws Exception { // create a problematic file name in the workspace FreeStyleProject p = createFreeStyleProject(); - if(Hudson.isWindows()) + if(Functions.isWindows()) p.getBuildersList().add(new BatchFile("echo > abc..def")); else p.getBuildersList().add(new Shell("touch abc..def")); @@ -67,7 +68,7 @@ public class DirectoryBrowserSupportTest extends HudsonTestCase { */ @Email("http://www.nabble.com/Status-Code-400-viewing-or-downloading-artifact-whose-filename-contains-two-consecutive-periods-tt21407604.html") public void testDoubleDots2() throws Exception { - if(Hudson.isWindows()) return; // can't test this on Windows + if(Functions.isWindows()) return; // can't test this on Windows // create a problematic file name in the workspace FreeStyleProject p = createFreeStyleProject(); diff --git a/test/src/test/java/hudson/tools/ToolLocationNodePropertyTest.java b/test/src/test/java/hudson/tools/ToolLocationNodePropertyTest.java index 2710d98529..0c8013afbc 100644 --- a/test/src/test/java/hudson/tools/ToolLocationNodePropertyTest.java +++ b/test/src/test/java/hudson/tools/ToolLocationNodePropertyTest.java @@ -24,6 +24,7 @@ package hudson.tools; +import hudson.Functions; import hudson.model.*; import hudson.slaves.DumbSlave; import hudson.tasks.Maven; @@ -117,7 +118,7 @@ public class ToolLocationNodePropertyTest extends HudsonTestCase { } private void configureDumpEnvBuilder() throws IOException { - if(Hudson.isWindows()) + if(Functions.isWindows()) project.getBuildersList().add(new BatchFile("set")); else project.getBuildersList().add(new Shell("export"));