Author: bodewig
Date: Wed Jun  4 03:34:07 2008
New Revision: 663051

URL: http://svn.apache.org/viewvc?rev=663051&view=rev
Log:
Add a new property to hold the current project's default target

Added:
    ant/core/trunk/src/tests/antunit/core/magic-names-test.xml   (with props)
Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/using.html
    ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java
    ant/core/trunk/src/main/org/apache/tools/ant/Project.java

Modified: ant/core/trunk/WHATSNEW
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=663051&r1=663050&r2=663051&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Jun  4 03:34:07 2008
@@ -71,7 +71,8 @@
  * 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 <project>'s default attribute.
 
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================

Modified: ant/core/trunk/docs/manual/using.html
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/using.html?rev=663051&r1=663050&r2=663051&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/using.html (original)
+++ ant/core/trunk/docs/manual/using.html Wed Jun  4 03:34:07 2008
@@ -307,6 +307,10 @@
 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 &lt;project&gt;.
+ant.project.default-target
+                    the name of the currently executing project's
+                    default target;  it is set via the default
+                    attribute of &lt;project&gt;.
 ant.java.version    the JVM version Ant detected; currently it can hold
                     the values &quot;1.2&quot;, &quot;1.3&quot;, 
&quot;1.4&quot; and &quot;1.5&quot;.
 </pre>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java?rev=663051&r1=663050&r2=663051&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java Wed Jun  4 
03:34:07 2008
@@ -202,5 +202,15 @@
      */
     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: [EMAIL PROTECTED]
+     * @since Ant 1.8.0
+     */
+    public static final String PROJECT_DEFAULT_TARGET
+        = "ant.project.default-target";
+
 }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Project.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Project.java?rev=663051&r1=663050&r2=663051&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Project.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Project.java Wed Jun  4 
03:34:07 2008
@@ -674,7 +674,7 @@
      * @see #setDefault(String)
      */
     public void setDefaultTarget(String defaultTarget) {
-        this.defaultTarget = defaultTarget;
+        setDefault(defaultTarget);
     }
 
     /**
@@ -694,6 +694,7 @@
      *                      no default target.
      */
     public void setDefault(String defaultTarget) {
+        setUserProperty(MagicNames.PROJECT_DEFAULT_TARGET,  defaultTarget);
         this.defaultTarget = defaultTarget;
     }
 

Added: ant/core/trunk/src/tests/antunit/core/magic-names-test.xml
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/core/magic-names-test.xml?rev=663051&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/core/magic-names-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/core/magic-names-test.xml Wed Jun  4 
03:34:07 2008
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns:au="antlib:org.apache.ant.antunit"
+         name="magicnames-test"
+         default="default target">
+
+  <target name="default target"/>
+
+  <target name="testProjectName">
+    <au:assertPropertyEquals
+       name="ant.project.name" value="magicnames-test"/>
+  </target>
+
+  <target name="testDefaultTarget">
+    <au:assertPropertyEquals
+       name="ant.project.default-target" value="default target"/>
+  </target>
+
+</project>

Propchange: ant/core/trunk/src/tests/antunit/core/magic-names-test.xml
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to