Browse Source

make ant.project.invoked-targets available for top-level tasks

https://bz.apache.org/bugzilla/show_bug.cgi?id=58908
master
Stefan Bodewig 9 years ago
parent
commit
494e865553
3 changed files with 25 additions and 7 deletions
  1. +11
    -6
      manual/properties.html
  2. +11
    -0
      src/main/org/apache/tools/ant/Main.java
  3. +3
    -1
      src/tests/antunit/core/magic-names-test.xml

+ 11
- 6
manual/properties.html View File

@@ -77,13 +77,18 @@ ant.project.invoked-targets
been specified on the command line (the IDE,
an <ant> task ...) when invoking the current
project.
This property is set when the first target is executed.
So you can't use it in the implicit target (directly
under the <project> tag).
This property is set properly when the first target is executed.
If you use it in the implicit target (directly
under the <project> tag) the list will be
empty if no target has been specified while it
will contain the project's default target in this
case for tasks nested into targets..
ant.java.version the JVM version Ant detected; currently it can hold
the values "1.7", "1.6", "1.5",
"1.4", "1.3" and "1.2".
ant.core.lib the absolute path of the <code>ant.jar</code> file.
the values &quot;1.9&quot;, &quot;1.8&quot;,
&quot;1.7&quot;, &quot;1.6&quot;, &quot;1.5&quot;,
&quot;1.4&quot;, &quot;1.3&quot; and
&quot;1.2&quot;. ant.core.lib the absolute path
of the <code>ant.jar</code> file.
</pre>

<p>There is also another property, but this is set by the launcher


+ 11
- 0
src/main/org/apache/tools/ant/Main.java View File

@@ -45,6 +45,7 @@ import org.apache.tools.ant.listener.SilentLogger;
import org.apache.tools.ant.property.GetProperty;
import org.apache.tools.ant.property.ResolvePropertyMap;
import org.apache.tools.ant.util.ClasspathUtils;
import org.apache.tools.ant.util.CollectionUtils;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.ProxySetup;

@@ -917,6 +918,16 @@ public class Main implements AntMain {
buildFile.getAbsolutePath());
project.setUserProperty(MagicNames.ANT_FILE_TYPE,
MagicNames.ANT_FILE_TYPE_FILE);

// this list doesn't contain the build files default target,
// which may be added later unless targets have been specified
// on the command line. Therefore the property gets set again
// in Project#executeTargets when we can be sure the list is
// complete.
// Setting it here allows top-level tasks to access the
// property.
project.setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS,
CollectionUtils.flattenToString(targets));
}

/**


+ 3
- 1
src/tests/antunit/core/magic-names-test.xml View File

@@ -17,7 +17,9 @@
-->
<project xmlns:au="antlib:org.apache.ant.antunit"
name="magicnames-test"
default="default target">
default="antunit">

<import file="../antunit-base.xml" />

<target name="default target"/>



Loading…
Cancel
Save