Browse Source

new attribute allowNativeBasedir for <ant>. Not yet documented. Not yet complete (doesn't work when basedir is a user or inherited property). Work in progress. Needed for PR 30569.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@677914 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 17 years ago
parent
commit
c1142173a2
4 changed files with 30 additions and 1 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/Project.java
  2. +21
    -0
      src/main/org/apache/tools/ant/taskdefs/Ant.java
  3. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/SubAnt.java
  4. +6
    -0
      src/tests/antunit/taskdefs/subant-test.xml

+ 1
- 1
src/main/org/apache/tools/ant/Project.java View File

@@ -822,7 +822,7 @@ public class Project implements ResourceFactory {
this.baseDir = baseDir;
setPropertyInternal(MagicNames.PROJECT_BASEDIR, this.baseDir.getPath());
String msg = "Project base dir set to: " + this.baseDir;
log(msg, MSG_VERBOSE);
log(msg, MSG_VERBOSE);
}

/**


+ 21
- 0
src/main/org/apache/tools/ant/taskdefs/Ant.java View File

@@ -106,6 +106,15 @@ public class Ant extends Task {
/** whether the target attribute was specified **/
private boolean targetAttributeSet = false;

/**
* Whether the basedir of the new project should be the same one
* as it would be when running the build file directly -
* independent of dir and/or inheritAll settings.
*
* @since Ant 1.8.0
*/
private boolean allowNativeBasedir = false;

/**
* simple constructor
*/
@@ -121,6 +130,16 @@ public class Ant extends Task {
bindToOwner(owner);
}

/**
* Whether the basedir of the new project should be the same one
* as it would be when running the build file directly -
* independent of dir and/or inheritAll settings.
*
* @since Ant 1.8.0
*/
public void setAllowNativeBasedir(boolean b) {
allowNativeBasedir = b;
}

/**
* If true, pass all properties to the new Ant project.
@@ -321,12 +340,14 @@ public class Ant extends Task {
initializeProject();

if (dir != null) {
if (!allowNativeBasedir) {
newProject.setBaseDir(dir);
if (savedDir != null) {
// has been set explicitly
newProject.setInheritedProperty(MagicNames.PROJECT_BASEDIR,
dir.getAbsolutePath());
}
}
} else {
dir = getProject().getBaseDir();
}


+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/SubAnt.java View File

@@ -553,6 +553,8 @@ public class SubAnt extends Task {

if (directory != null) {
antTask.setDir(directory);
} else {
antTask.setAllowNativeBasedir(true);
}

antTask.setInheritAll(inheritAll);


+ 6
- 0
src/tests/antunit/taskdefs/subant-test.xml View File

@@ -59,4 +59,10 @@
target="testSubAntDoesntSetBasedir"/>
</target>

<target name="testSubAntDoesntSetBasedirAfterAntWithDirWhenNativeDir">
<ant antfile="${ant.file}" dir="${basedir}"
target="testSubAntDoesntSetBasedir"
allowNativeBaseDir="true"/>
</target>

</project>

Loading…
Cancel
Save