Repository: ant Updated Branches: refs/heads/master c7ab4faae -> 706d00212
More MagicNames Project: http://git-wip-us.apache.org/repos/asf/ant/repo Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/706d0021 Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/706d0021 Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/706d0021 Branch: refs/heads/master Commit: 706d002129865450494a0938c63deb525afd53a1 Parents: c7ab4fa Author: Gintas Grigelionis <[email protected]> Authored: Wed Oct 24 22:35:02 2018 +0200 Committer: Gintas Grigelionis <[email protected]> Committed: Wed Oct 24 22:35:02 2018 +0200 ---------------------------------------------------------------------- .../apache/tools/ant/helper/ProjectHelper2.java | 4 +- .../tools/ant/helper/ProjectHelperImpl.java | 5 +- src/main/org/apache/tools/ant/types/Path.java | 57 ++++++++------------ .../apache/tools/ant/taskdefs/DirnameTest.java | 4 +- .../apache/tools/ant/taskdefs/PropertyTest.java | 3 +- .../apache/tools/ant/util/JavaEnvUtilsTest.java | 4 +- 6 files changed, 34 insertions(+), 43 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant/blob/706d0021/src/main/org/apache/tools/ant/helper/ProjectHelper2.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java index f65a172..22ebee0 100644 --- a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java +++ b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java @@ -820,8 +820,8 @@ public class ProjectHelper2 extends ProjectHelper { return; } // set explicitly before starting ? - if (project.getProperty("basedir") != null) { - project.setBasedir(project.getProperty("basedir")); + if (project.getProperty(MagicNames.PROJECT_BASEDIR) != null) { + project.setBasedir(project.getProperty(MagicNames.PROJECT_BASEDIR)); } else { // Default for baseDir is the location of the build file. if (baseDir == null) { http://git-wip-us.apache.org/repos/asf/ant/blob/706d0021/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java b/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java index 175a39a..e6461b6 100644 --- a/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java +++ b/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java @@ -28,6 +28,7 @@ import java.util.Locale; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.IntrospectionHelper; import org.apache.tools.ant.Location; +import org.apache.tools.ant.MagicNames; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.RuntimeConfigurable; @@ -423,8 +424,8 @@ public class ProjectHelperImpl extends ProjectHelper { helperImpl.project.addReference(id, helperImpl.project); } - if (helperImpl.project.getProperty("basedir") != null) { - helperImpl.project.setBasedir(helperImpl.project.getProperty("basedir")); + if (helperImpl.project.getProperty(MagicNames.PROJECT_BASEDIR) != null) { + helperImpl.project.setBasedir(helperImpl.project.getProperty(MagicNames.PROJECT_BASEDIR)); } else { if (baseDir == null) { helperImpl.project.setBasedir(helperImpl.buildFileParent.getAbsolutePath()); http://git-wip-us.apache.org/repos/asf/ant/blob/706d0021/src/main/org/apache/tools/ant/types/Path.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java index d2acd8c..08f5f22 100644 --- a/src/main/org/apache/tools/ant/types/Path.java +++ b/src/main/org/apache/tools/ant/types/Path.java @@ -595,7 +595,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { if (JavaEnvUtils.isKaffe()) { // newer versions of Kaffe (1.1.1+) won't have this, // but this will be sorted by FileSet anyway. - File kaffeShare = new File(System.getProperty("java.home") + File kaffeShare = new File(JavaEnvUtils.getJavaHome() + File.separator + "share" + File.separator + "kaffe"); if (kaffeShare.isDirectory()) { @@ -612,57 +612,44 @@ public class Path extends DataType implements Cloneable, ResourceCollection { // TODO is this code still necessary? is there any 1.2+ port? // Pull in *.zip from packages directory FileSet msZipFiles = new FileSet(); - msZipFiles.setDir(new File(System.getProperty("java.home") - + File.separator + "Packages")); + msZipFiles.setDir(new File(JavaEnvUtils.getJavaHome() + + File.separator + "Packages")); msZipFiles.setIncludes("*.ZIP"); addFileset(msZipFiles); } else { // JDK 1.2+ seems to set java.home to the JRE directory. - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + "lib" - + File.separator + "rt.jar")); + addExisting(new Path(null, JavaEnvUtils.getJavaHome() + + File.separator + "lib" + File.separator + "rt.jar")); // Just keep the old version as well and let addExisting // sort it out. - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + "jre" - + File.separator + "lib" - + File.separator + "rt.jar")); + addExisting(new Path(null, JavaEnvUtils.getJavaHome() + + File.separator + "jre" + File.separator + "lib" + + File.separator + "rt.jar")); // Sun's and Apple's 1.4 have JCE and JSSE in separate jars. for (String secJar : Arrays.asList("jce", "jsse")) { - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + "lib" - + File.separator + secJar + ".jar")); - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + ".." - + File.separator + "Classes" - + File.separator + secJar + ".jar")); + addExisting(new Path(null, JavaEnvUtils.getJavaHome() + + File.separator + "lib" + + File.separator + secJar + ".jar")); + addExisting(new Path(null, JavaEnvUtils.getJavaHome() + + File.separator + ".." + File.separator + "Classes" + + File.separator + secJar + ".jar")); } // IBM's 1.4 has rt.jar split into 4 smaller jars and a combined // JCE/JSSE in security.jar. for (String ibmJar : Arrays.asList("core", "graphics", "security", "server", "xml")) { - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + "lib" - + File.separator + ibmJar + ".jar")); + addExisting(new Path(null, JavaEnvUtils.getJavaHome() + + File.separator + "lib" + File.separator + ibmJar + ".jar")); } // Added for MacOS X - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + ".." - + File.separator + "Classes" - + File.separator + "classes.jar")); - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + ".." - + File.separator + "Classes" - + File.separator + "ui.jar")); + addExisting(new Path(null, JavaEnvUtils.getJavaHome() + + File.separator + ".." + File.separator + "Classes" + + File.separator + "classes.jar")); + addExisting(new Path(null, JavaEnvUtils.getJavaHome() + + File.separator + ".." + File.separator + "Classes" + + File.separator + "ui.jar")); } } http://git-wip-us.apache.org/repos/asf/ant/blob/706d0021/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java index 72e1a99..585c847 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java @@ -23,6 +23,7 @@ import static org.junit.Assume.assumeFalse; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildFileRule; +import org.apache.tools.ant.MagicNames; import org.apache.tools.ant.taskdefs.condition.Os; import org.junit.Before; import org.junit.Rule; @@ -78,7 +79,8 @@ public class DirnameTest { @Test public void test5() { buildRule.executeTarget("test5"); - assertEquals("dirname failed", buildRule.getProject().getProperty("basedir"), + assertEquals("dirname failed", + buildRule.getProject().getProperty(MagicNames.PROJECT_BASEDIR), buildRule.getProject().getProperty("base.dir")); } http://git-wip-us.apache.org/repos/asf/ant/blob/706d0021/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java index 4115339..1762c22 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java @@ -26,6 +26,7 @@ import static org.junit.Assume.assumeNoException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildFileRule; +import org.apache.tools.ant.MagicNames; import org.apache.tools.ant.util.FileUtils; import org.junit.Before; import org.junit.Rule; @@ -83,7 +84,7 @@ public class PropertyTest { @Test public void test5() { - String baseDir = buildRule.getProject().getProperty("basedir"); + String baseDir = buildRule.getProject().getProperty(MagicNames.PROJECT_BASEDIR); String uri = FILE_UTILS.toURI(baseDir + "/property3.properties"); buildRule.getProject().setNewProperty("test5.url", uri); http://git-wip-us.apache.org/repos/asf/ant/blob/706d0021/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java index a93f4f2..ad03ed3 100644 --- a/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java @@ -51,7 +51,7 @@ public class JavaEnvUtilsTest { @Test public void testGetExecutableWindows() { assumeTrue("Test only runs on windows", Os.isFamily("windows")); - String javaHome = FILE_UTILS.normalize(System.getProperty("java.home")) + String javaHome = FILE_UTILS.normalize(JavaEnvUtils.getJavaHome()) .getAbsolutePath(); String j = JavaEnvUtils.getJreExecutable("java"); @@ -89,7 +89,7 @@ public class JavaEnvUtilsTest { public void testGetExecutableMostPlatforms() { assumeFalse("Test only runs on non Netware and non Windows systems", Os.isName("netware") || Os.isFamily("windows")); - String javaHome = FILE_UTILS.normalize(System.getProperty("java.home")).getAbsolutePath(); + String javaHome = FILE_UTILS.normalize(JavaEnvUtils.getJavaHome()).getAbsolutePath(); // could still be OS/2 String extension = Os.isFamily("dos") ? ".exe" : "";
