Browse Source

More MagicNames

master
Gintas Grigelionis 6 years ago
parent
commit
706d002129
6 changed files with 34 additions and 43 deletions
  1. +2
    -2
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java
  2. +3
    -2
      src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
  3. +22
    -35
      src/main/org/apache/tools/ant/types/Path.java
  4. +3
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java
  5. +2
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
  6. +2
    -2
      src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java

+ 2
- 2
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -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) {


+ 3
- 2
src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java View File

@@ -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());


+ 22
- 35
src/main/org/apache/tools/ant/types/Path.java View File

@@ -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"));
}
}



+ 3
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java View File

@@ -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"));
}



+ 2
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java View File

@@ -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);



+ 2
- 2
src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java View File

@@ -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" : "";


Loading…
Cancel
Save