Browse Source

Add a new property to hold the current project's default target

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@663051 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 17 years ago
parent
commit
792a2f16f0
5 changed files with 52 additions and 2 deletions
  1. +2
    -1
      WHATSNEW
  2. +4
    -0
      docs/manual/using.html
  3. +10
    -0
      src/main/org/apache/tools/ant/MagicNames.java
  4. +2
    -1
      src/main/org/apache/tools/ant/Project.java
  5. +34
    -0
      src/tests/antunit/core/magic-names-test.xml

+ 2
- 1
WHATSNEW View File

@@ -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 <project>'s default attribute.

Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================


+ 4
- 0
docs/manual/using.html View File

@@ -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 &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>


+ 10
- 0
src/main/org/apache/tools/ant/MagicNames.java View File

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

}


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

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



+ 34
- 0
src/tests/antunit/core/magic-names-test.xml View File

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

Loading…
Cancel
Save