diff --git a/WHATSNEW b/WHATSNEW index dc082ff4b..6b2233a81 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -71,7 +71,8 @@ Other changes: * Fixcrlf now gives better error messages on bad directory attributes. Bugzilla report 43936 - + * a new property ant.project.default-target holds the value of the + current 's default attribute. Changes from Ant 1.7.0 TO Ant 1.7.1 ============================================= diff --git a/docs/manual/using.html b/docs/manual/using.html index d10f56b64..3ceb05378 100644 --- a/docs/manual/using.html +++ b/docs/manual/using.html @@ -307,6 +307,10 @@ ant.file the absolute path of the buildfile. ant.version the version of Ant ant.project.name the name of the project that is currently executing; it is set in the name attribute of <project>. +ant.project.default-target + the name of the currently executing project's + default target; it is set via the default + attribute of <project>. ant.java.version the JVM version Ant detected; currently it can hold the values "1.2", "1.3", "1.4" and "1.5". diff --git a/src/main/org/apache/tools/ant/MagicNames.java b/src/main/org/apache/tools/ant/MagicNames.java index e004cebf7..86a791828 100644 --- a/src/main/org/apache/tools/ant/MagicNames.java +++ b/src/main/org/apache/tools/ant/MagicNames.java @@ -202,5 +202,15 @@ public final class MagicNames { */ public static final String PROJECT_NAME = "ant.project.name"; + /** + * Name of the property holding the default target of the + * currently executing project, if one has been specified. + * + * Value: {@value} + * @since Ant 1.8.0 + */ + public static final String PROJECT_DEFAULT_TARGET + = "ant.project.default-target"; + } diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index 31854459e..f2f8ffa53 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -674,7 +674,7 @@ public class Project implements ResourceFactory { * @see #setDefault(String) */ public void setDefaultTarget(String defaultTarget) { - this.defaultTarget = defaultTarget; + setDefault(defaultTarget); } /** @@ -694,6 +694,7 @@ public class Project implements ResourceFactory { * no default target. */ public void setDefault(String defaultTarget) { + setUserProperty(MagicNames.PROJECT_DEFAULT_TARGET, defaultTarget); this.defaultTarget = defaultTarget; } diff --git a/src/tests/antunit/core/magic-names-test.xml b/src/tests/antunit/core/magic-names-test.xml new file mode 100644 index 000000000..cc82088ad --- /dev/null +++ b/src/tests/antunit/core/magic-names-test.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + +