ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r1479422 - in /ant/core/trunk: ./ manual/ manual/Types/ src/etc/checkstyle/ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/attribute/ src/main/org/apache/tools/ant/taskdefs/ src/tests/antunit/core/
Date Sun, 05 May 2013 23:49:49 GMT
Author: antoine
Date: Sun May  5 23:49:49 2013
New Revision: 1479422

URL: http://svn.apache.org/r1479422
Log:
adding if and unless namespaces allowing to put conditions on all tasks and nested elements. Code written by Peter Reilly. Bugzilla PR 43362.

Added:
    ant/core/trunk/manual/ifunless.html
      - copied, changed from r1479367, ant/core/trunk/manual/targets.html
    ant/core/trunk/src/main/org/apache/tools/ant/DefaultDefinitions.java   (with props)
    ant/core/trunk/src/main/org/apache/tools/ant/attribute/
    ant/core/trunk/src/main/org/apache/tools/ant/attribute/AttributeNamespace.java   (with props)
    ant/core/trunk/src/main/org/apache/tools/ant/attribute/BaseIfAttribute.java   (with props)
    ant/core/trunk/src/main/org/apache/tools/ant/attribute/EnableAttribute.java   (with props)
    ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfBlankAttribute.java   (with props)
    ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfSetAttribute.java   (with props)
    ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfTrueAttribute.java   (with props)
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AttributeNamespaceDef.java   (with props)
    ant/core/trunk/src/tests/antunit/core/ant-attribute-test.xml   (with props)
Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/manual/Types/namespace.html
    ant/core/trunk/manual/conceptstypeslist.html
    ant/core/trunk/src/etc/checkstyle/checkstyle-config
    ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
    ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java
    ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java
    ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
    ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/defaults.properties

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1479422&r1=1479421&r2=1479422&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sun May  5 23:49:49 2013
@@ -29,6 +29,9 @@ Other changes:
 
  * simplifying Execute.getEnvironmentVariables since we are only running on Java 1.5 or higher now
 
+ * Add conditional attributes
+   Bugzilla report 43362
+
 Changes from Ant 1.8.4 TO Ant 1.9.0
 ===================================
 

Modified: ant/core/trunk/manual/Types/namespace.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/manual/Types/namespace.html?rev=1479422&r1=1479421&r2=1479422&view=diff
==============================================================================
--- ant/core/trunk/manual/Types/namespace.html (original)
+++ ant/core/trunk/manual/Types/namespace.html Sun May  5 23:49:49 2013
@@ -152,6 +152,10 @@
       </li>
     </ul>
     <p>
+      In Ant 1.9.1 two attribute namespaces ant:if and ant:unless are added in order to allow to insert elements
+      conditionally
+    </p>
+    <p>
       Other attributes are simply ignored.
     </p>
     <p>

Modified: ant/core/trunk/manual/conceptstypeslist.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/manual/conceptstypeslist.html?rev=1479422&r1=1479421&r2=1479422&view=diff
==============================================================================
--- ant/core/trunk/manual/conceptstypeslist.html (original)
+++ ant/core/trunk/manual/conceptstypeslist.html Sun May  5 23:49:49 2013
@@ -35,6 +35,7 @@
 <li><a href="sysclasspath.html">build.sysclasspath</a></li>
 <li><a href="javacprops.html">Ant properties controlling javac</a></li>
 <li><a href="Tasks/common.html">Common Attributes</a></li>
+<li><a href="ifunless.html">If and Unless Attributes</a></li>
 </ul>
 
 <h3>List of Types</h3>

Copied: ant/core/trunk/manual/ifunless.html (from r1479367, ant/core/trunk/manual/targets.html)
URL: http://svn.apache.org/viewvc/ant/core/trunk/manual/ifunless.html?p2=ant/core/trunk/manual/ifunless.html&p1=ant/core/trunk/manual/targets.html&r1=1479367&r2=1479422&rev=1479422&view=diff
==============================================================================
--- ant/core/trunk/manual/targets.html (original)
+++ ant/core/trunk/manual/ifunless.html Sun May  5 23:49:49 2013
@@ -19,282 +19,46 @@
 <head>
   <meta http-equiv="Content-Language" content="en-us"/>
   <link rel="stylesheet" type="text/css" href="stylesheets/style.css"/>
-  <title>Targets and Extension-Points</title>
+  <title>If and Unless on all tasks/nested elements</title>
 </head>
 
 <body>
-  <h1><a name="targets">Targets</a></h1>
+  <h1><a name="if_and_unless">If And Unless</a></h1>
 
-  <p>A target is a container of tasks that cooperate to reach a
-    desired state during the build process.</p>
+  <p>Since Ant 1.9.1 it is possible to add if and unless attributes on all tasks and nested elements using special namespaces.</p>
 
-  <p>Targets can depend on other targets and Apache Ant ensures that these
-    other targets have been executed before the current target. For
-    example you might have a target for compiling and a
-    target for creating a distributable. You can only build a
-    distributable when you have compiled first, so the distribute
-    target <i>depends on</i> the compile target.</p>
-
-  <p>Ant tries to execute the targets in the <code>depends</code>
-    attribute in the order they appear (from left to right). Keep in
-    mind that it is possible that a target can get executed earlier
-    when an earlier target depends on it:</p>
+  <p>In order to use this feature you need to add the following namespace declarations</p>
+  <blockquote><pre>
+    xmlns:if=&quot;ant:if&quot;
+    xmlns:unless=&quot;ant:unless&quot;
+    </pre>
+  </blockquote>
+
+  <p>The if and unless namespaces support the following 3 conditions :
+  <ul>
+    <li>true</li>true if the value of the property evaluates to true
+    <li>blank</li>true if the value of the property is null or empty
+    <li>set</li>true if the property is set
+  </ul></p>
 
 <blockquote>
-<pre>&lt;target name=&quot;A&quot;/&gt;
-&lt;target name=&quot;B&quot; depends=&quot;A&quot;/&gt;
-&lt;target name=&quot;C&quot; depends=&quot;B&quot;/&gt;
-&lt;target name=&quot;D&quot; depends=&quot;C,B,A&quot;/&gt;</pre>
+<pre>
+&lt;project name=&quot;tryit&quot;
+ xmlns:if=&quot;ant:if&quot;
+ xmlns:unless=&quot;ant:unless&quot;
+&gt;
+ &lt;exec executable=&quot;java&quot;&gt;
+   &lt;arg line=&quot;-X&quot; if:true=&quot;showextendedparams&quot;/&gt;
+   &lt;arg line=&quot;-version&quot; unless:true=&quot;showextendedparams&quot;/&gt;
+ &lt;/exec&gt;
+ &lt;condition property=&quot;onmac&quot;&gt;
+   &lt;os family=&quot;mac&quot;/&gt;
+ &lt;/condition&gt;
+ &lt;echo if:set=&quot;onmac&quot;&gt;running on MacOS&lt;/echo&gt;
+ &lt;echo unless:set=&quot;onmac&quot;&gt;not running on MacOS&lt;/echo&gt;
+&lt;/project&gt;
+</pre>
 </blockquote>
 
-  <p>Suppose we want to execute target D. From its
-    <code>depends</code> attribute, you might think that first target
-    C, then B and then A is executed.  Wrong! C depends on B, and B
-    depends on A, so first A is executed, then B, then C, and finally
-    D.</p>
-    
-  <blockquote><pre><b>Call-Graph:</b>  A --> B --> C --> D</pre></blockquote>
-
-  <p>In a chain of dependencies stretching back from a given target
-    such as D above, each target gets executed only once, even when
-    more than one target depends on it. Thus, executing the D target
-    will first result in C being called, which in turn will first call
-    B, which in turn will first call A. After A, then B, then C have
-    executed, execution returns to the dependency list of D, which
-    will <u>not</u> call B and A, since they were already called in
-    process of dependency resolution for C and B respectively as
-    dependencies of D. Had no such dependencies been discovered in
-    processing C and B, B and A would have been executed after C in
-    processing D's dependency list.</p>
-
-  <p>A target also has the ability to perform its execution if (or
-    unless) a property has been set. This allows, for example, better
-    control on the building process depending on the state of the
-    system (java version, OS, command-line property defines, etc.).
-    To make a target <i>sense</i> this property, you should add
-    the <code>if</code> (or <code>unless</code>) attribute with the
-    name of the property that the target should react
-    to. <strong>Note:</strong> In the most simple case Ant will only
-    check whether the property has been set, the value doesn't matter,
-    but using property expansions you can build more complex
-    conditions.  See
-    <a href="properties.html#if+unless">the properties page</a> for
-    more details.  For example:</p>
-
-<blockquote>
-  <pre>&lt;target name=&quot;build-module-A&quot; if=&quot;module-A-present&quot;/&gt;</pre>
-  <pre>&lt;target name=&quot;build-own-fake-module-A&quot; unless=&quot;module-A-present&quot;/&gt;</pre>
-</blockquote>
-
-  <p>In the first example, if the <code>module-A-present</code>
-    property is set (to any value, e.g. <i>false</i>), the target will
-    be run. In the second example, if
-    the <code>module-A-present</code> property is set (again, to any
-    value), the target will not be run.</p>
-
-  <p>Only one propertyname can be specified in the if/unless
-    clause. If you want to check multiple conditions, you can use a
-    dependend target for computing the result for the check:</p>
-
-<blockquote><pre>
-&lt;target name="myTarget" depends="myTarget.check" if="myTarget.run"&gt;
-    &lt;echo&gt;Files foo.txt and bar.txt are present.&lt;/echo&gt;
-&lt/target&gt;
-
-&lt;target name="myTarget.check"&gt;
-    &lt;condition property="myTarget.run"&gt;
-        &lt;and&gt;
-            &lt;available file="foo.txt"/&gt;
-            &lt;available file="bar.txt"/&gt;
-        &lt;/and&gt;
-    &lt;/condition&gt;
-&lt/target&gt;
-</pre></blockquote>
-
-  <blockquote><pre><b>Call-Graph:</b>  myTarget.check --> maybe(myTarget)</pre></blockquote>
-
-  <p>If no <code>if</code> and no <code>unless</code> attribute is
-    present, the target will always be executed.</p>
-
-  <p><b>Important:</b> the <code>if</code> and <code>unless</code>
-    attributes only enable or disable the target to which they are
-    attached. They do not control whether or not targets that a
-    conditional target depends upon get executed.  In fact, they do
-    not even get evaluated until the target is about to be executed,
-    and all its predecessors have already run.
-
-  <p>The optional <code>description</code> attribute can be used to
-    provide a one-line description of this target, which is printed by
-    the <code>-projecthelp</code> command-line option. Targets without
-    such a description are deemed internal and will not be listed,
-    unless either the <code>-verbose</code> or <code>-debug</code>
-    option is used.</p>
-
-  <p>It is a good practice to place
-    your <a href="Tasks/tstamp.html">tstamp</a> tasks in a
-    so-called <i>initialization</i> target, on which all other targets
-    depend. Make sure that target is always the first one in the
-    depends list of the other targets. In this manual, most
-    initialization targets have the name <code>&quot;init&quot;</code>.</p>
-    <blockquote><pre>
-    &lt;project&gt;
-        &lt;target name=&quot;init&quot;&gt;
-            &lt;tstamp/&gt;
-        &lt;/target&gt;
-        &lt;target name=&quot;otherTarget&quot; depends=&quot;init&quot;&gt;
-            ...
-        &lt;/target&gt;
-    &lt;/project&gt;
-    </pre></blockquote>
-
-  <p>Especially if you only have a few tasks you also could place these
-    tasks directly under the project tag (since Ant 1.6.0):</p>
-    <blockquote><pre>
-    &lt;project&gt;
-        &lt;tstamp/&gt;
-    &lt;/project&gt;
-    </pre></blockquote>
-
-  <p>If the depends attribute and the if/unless attribute are set, the
-    depends attribute is executed first.</p>
-
-  <p>A target has the following attributes:</p>
-
-  <table border="1" cellpadding="2" cellspacing="0">
-    <tr>
-      <td valign="top"><b>Attribute</b></td>
-      <td valign="top"><b>Description</b></td>
-      <td align="center" valign="top"><b>Required</b></td>
-    </tr>
-    <tr>
-      <td valign="top">name</td>
-      <td valign="top">the name of the target.</td>
-      <td align="center" valign="top">Yes</td>
-    </tr>
-    <tr>
-      <td valign="top">depends</td>
-      <td valign="top">a comma-separated list of names of targets on
-        which this target depends.</td>
-      <td align="center" valign="top">No</td>
-    </tr>
-    <tr>
-      <td valign="top">if</td>
-      <td valign="top">the name of the property that must be set in
-        order for this target to execute,
-        or <a href="properties.html#if+unless">something evaluating to
-          true</a>.</td>
-      <td align="center" valign="top">No</td>
-    </tr>
-    <tr>
-      <td valign="top">unless</td>
-      <td valign="top">the name of the property that must not be set
-        in order for this target to execute,
-        or <a href="properties.html#if+unless">something evaluating to
-        false</a>.</td>
-      <td align="center" valign="top">No</td>
-    </tr>
-    <tr>
-      <td valign="top">description</td>
-      <td valign="top">a short description of this target's function.</td>
-      <td align="center" valign="top">No</td>
-    </tr>
-    <tr>
-      <td valign="top">extensionOf</td>
-      <td valign="top">Adds the current target to the depends list of
-        the named <a href="#extension-points">extension-point</a>.
-        <em>since Ant 1.8.0.</em></td>
-      <td align="center" valign="top">No</td>
-    </tr>
-    <tr>
-      <td valign="top">onMissingExtensionPoint</td>
-      <td valign="top">What to do if this target tries to extend a
-        missing
-        <a href="#extension-points">extension-point</a>. ("fail",
-        "warn", "ignore").
-        <em>since Ant 1.8.2.</em></td>
-      <td align="center" valign="top">No. Not allowed unless
-        <code>extensionOf</code> is present. Defaults to <code>fail</code>. 
-      </td>
-    </tr>
-  </table>
-
-  <p>A target name can be any alphanumeric string valid in the
-    encoding of the XML file. The empty string &quot;&quot; is in this
-    set, as is comma &quot;,&quot; and space &quot; &quot;.  Please
-    avoid using these, as they will not be supported in future Ant
-    versions because of all the confusion they cause on command line and IDE. IDE support of
-    unusual target names, or any target name containing spaces, varies
-    with the IDE.</p>
-
-  <p>Targets beginning with a hyphen such
-    as <code>&quot;-restart&quot;</code> are valid, and can be used to
-    name targets that should not be called directly from the command
-    line. <br>
-    For Ants main class every option starting with hyphen is an
-    option for Ant itself and not a target. For that reason calling these
-    target from command line is not possible. On the other hand IDEs usually
-    don't use Ants main class as entry point and calling them from the IDE
-    is usually possible.</p>
-
-  <h1><a name="extension-points">Extension-Points</a></h1>
-
-  <p><em>since Ant 1.8.0.</em></p>
-
-  <p>Extension-Points are similar to targets in that they have a name and
-    a depends list and can be executed from the command line.  Just
-    like targets they represent a state during the build process.</p>
-
-  <p>Unlike targets they don't contain any tasks, their main purpose
-    is to collect targets that contribute to the desired state in
-    their depends list.</p>
-
-  <p>Targets can add themselves to an extension-points's depends list via
-    their extensionOf attribute.  The targets that add themselves will be
-    added after the targets of the explicit depends-attribute of the
-    extension-point, if multiple targets add themselves, their relative
-    order is not defined.</p>
-
-  <p>The main purpose of an extension-point is to act as an extension
-    point for build files designed to
-    be <a href="Tasks/import.html">imported</a>.  In the imported
-    file an extension-point defines a state that must be reached and
-    targets from other build files can join the depends list of said
-    extension-point in order to contribute to that state.</p>
-
-  <p>For example your imported build file may need to compile code, it
-    might look like:</p>
-<blockquote><pre>
-&lt;target name="create-directory-layout"&gt;
-   ...
-&lt;/target&gt;
-&lt;extension-point name="ready-to-compile"
-              depends="create-directory-layout"/&gt;
-&lt;target name="compile" depends="ready-to-compile"&gt;
-   ...
-&lt;/target&gt;
-</pre></blockquote>
-
-  <blockquote><pre><b>Call-Graph:</b>  create-directory-layout --> 'empty slot' --> compile</pre></blockquote>
-
-
-  <p>And you need to generate some source before compilation, then in
-    your main build file you may use something like</p>
-<blockquote><pre>
-&lt;target name="generate-sources"
-        extensionOf="ready-to-compile"&gt;
-   ...
-&lt;/target&gt;
-</pre></blockquote>
-
-  <blockquote><pre><b>Call-Graph:</b>  create-directory-layout --> generate-sources  --> compile</pre></blockquote>
-
-
-  <p>This will ensure that the <em>generate-sources</em> target is
-    executed before the <em>compile</em> target.</p>
-
-  <p>Don't rely on the order of the depends list,
-    if <em>generate-sources</em> depends
-    on <em>create-directory-layout</em> then it must explicitly depend
-    on it via its own depends attribute.</p>
 </body>
 </html>

Modified: ant/core/trunk/src/etc/checkstyle/checkstyle-config
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/checkstyle/checkstyle-config?rev=1479422&r1=1479421&r2=1479422&view=diff
==============================================================================
--- ant/core/trunk/src/etc/checkstyle/checkstyle-config (original)
+++ ant/core/trunk/src/etc/checkstyle/checkstyle-config Sun May  5 23:49:49 2013
@@ -96,8 +96,8 @@
     <module name="IllegalInstantiation">
       <property name="classes" value="java.lang.Boolean"/>
     </module>
-    <module name="InnerAssignment"/>
-    <module name="MagicNumber"/>
+    <!-- <module name="InnerAssignment"/> -->
+    <!-- <module name="MagicNumber"/> -->
     <module name="MissingSwitchDefault"/>
     <!-- Allow redundant throw declarations for doc purposes 
     <module name="RedundantThrows">
@@ -120,7 +120,7 @@
       <property name="format" value="\s+$"/>
       <property name="message" value="Line has trailing spaces."/>
     </module>
-    <module name="TodoComment"/>
+    <!-- <module name="TodoComment"/> -->
     <module name="UpperEll"/>
     <!-- allow comment suppression of checks -->
     <module name="FileContentsHolder"/>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java?rev=1479422&r1=1479421&r2=1479422&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java Sun May  5 23:49:49 2013
@@ -316,6 +316,7 @@ public class ComponentHelper  {
     public void initDefaultDefinitions() {
         initTasks();
         initTypes();
+        new DefaultDefinitions(this).execute();
     }
 
     /**

Added: ant/core/trunk/src/main/org/apache/tools/ant/DefaultDefinitions.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DefaultDefinitions.java?rev=1479422&view=auto
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/DefaultDefinitions.java (added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/DefaultDefinitions.java Sun May  5 23:49:49 2013
@@ -0,0 +1,75 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.tools.ant;
+
+/**
+ * Default definitions.
+ */
+public final class DefaultDefinitions {
+    private static final String IF_NAMESPACE = "ant:if";
+    private static final String UNLESS_NAMESPACE = "ant:unless";
+    private static final String OATA = "org.apache.tools.ant.";
+
+    private final ComponentHelper componentHelper;
+
+    /**
+     * Create a default definitions object.
+     * @param componentHelper the componenthelper to initialize.
+     */
+    public DefaultDefinitions(ComponentHelper componentHelper) {
+        this.componentHelper = componentHelper;
+    }
+
+    /**
+     * Register the defintions.
+     */
+    public void execute() {
+        attributeNamespaceDef(IF_NAMESPACE);
+        attributeNamespaceDef(UNLESS_NAMESPACE);
+
+        ifUnlessDef("true", "IfTrueAttribute");
+        ifUnlessDef("set", "IfSetAttribute");
+        ifUnlessDef("blank", "IfBlankAttribute");
+    }
+
+    private void attributeNamespaceDef(String ns) {
+        AntTypeDefinition def = new AntTypeDefinition();
+        def.setName(ProjectHelper.nsToComponentName(ns));
+        def.setClassName(OATA + "attribute.AttributeNamespace");
+        def.setClassLoader(getClass().getClassLoader());
+        def.setRestrict(true);
+        componentHelper.addDataTypeDefinition(def);
+    }
+
+    private void ifUnlessDef(String name, String base) {
+        String classname =  OATA + "attribute." + base;
+        componentDef(IF_NAMESPACE, name, classname);
+        componentDef(UNLESS_NAMESPACE, name, classname + "$Unless");
+    }
+
+    private void componentDef(String ns, String name, String classname) {
+        AntTypeDefinition def = new AntTypeDefinition();
+        String n = ProjectHelper.genComponentName(ns, name);
+        def.setName(ProjectHelper.genComponentName(ns, name));
+        def.setClassName(classname);
+        def.setClassLoader(getClass().getClassLoader());
+        def.setRestrict(true);
+        componentHelper.addDataTypeDefinition(def);
+    }
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/DefaultDefinitions.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=1479422&r1=1479421&r2=1479422&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 Sun May  5 23:49:49 2013
@@ -276,5 +276,9 @@ public final class MagicNames {
      * @since Ant 1.9.0
      */
     public static final String ANT_VM_LAUNCHER_REF_ID = "ant.vmLauncher";
+    /** Name of the namespace "type" (note: cannot be used as an element)
+     *  @since  Ant 1.9.1
+     * */
+    public static final String ATTRIBUTE_NAMESPACE = "attribute namespace";
 }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java?rev=1479422&r1=1479421&r2=1479422&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java Sun May  5 23:49:49 2013
@@ -43,6 +43,11 @@ public class ProjectHelper {
     /** The URI for antlib current definitions */
     public static final String ANT_CURRENT_URI      = "ant:current";
 
+    /** The URI for ant specific attributes
+     * @since Ant 1.9.1
+     * */
+    public static final String ANT_ATTRIBUTE_URI      = "ant:attribute";
+
     /** The URI for defined types/tasks - the format is antlib:<package> */
     public static final String ANTLIB_URI     = "antlib:";
 
@@ -523,6 +528,16 @@ public class ProjectHelper {
     }
 
     /**
+     * Convert an attribute namespace to a "component name".
+     * @param ns the xml namespace uri.
+     * @return the converted value.
+     * @since Ant 1.9.1
+     */
+    public static String nsToComponentName(String ns) {
+        return "attribute namespace:" + ns;
+    }
+
+    /**
      * Add location to build exception.
      * @param ex the build exception, if the build exception
      *           does not include

Modified: ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java?rev=1479422&r1=1479421&r2=1479422&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java Sun May  5 23:49:49 2013
@@ -27,6 +27,8 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map.Entry;
 
+import org.apache.tools.ant.attribute.EnableAttribute;
+
 import org.apache.tools.ant.util.CollectionUtils;
 import org.apache.tools.ant.taskdefs.MacroDef.Attribute;
 import org.apache.tools.ant.taskdefs.MacroInstance;
@@ -64,6 +66,9 @@ public class RuntimeConfigurable impleme
      */
     private transient AttributeList attributes;
 
+    // The following is set to true if any of the attributes are namespaced
+    private transient boolean namespacedAttribute = false;
+
     /** Attribute names and values. While the XML spec doesn't require
      *  preserving the order ( AFAIK ), some ant tests do rely on the
      *  exact order.
@@ -113,6 +118,73 @@ public class RuntimeConfigurable impleme
         proxyConfigured = false;
     }
 
+    private static class EnableAttributeConsumer {
+        public void add(EnableAttribute b) {
+            // Ignore
+        }
+    }
+
+    /**
+     * Check if an UE is enabled.
+     * This looks tru the attributes and checks if there
+     * are any Ant attributes, and if so, the method calls the
+     * isEnabled() method on them.
+     * @param owner the UE that owns this RC.
+     * @return true if enabled, false if any of the ant attribures return
+     *              false.
+     */
+    public boolean isEnabled(UnknownElement owner) {
+        if (!namespacedAttribute) {
+            return true;
+        }
+        ComponentHelper componentHelper = ComponentHelper
+            .getComponentHelper(owner.getProject());
+
+        IntrospectionHelper ih
+            = IntrospectionHelper.getHelper(
+                owner.getProject(), EnableAttributeConsumer.class);
+        for (int i = 0; i < attributeMap.keySet().size(); ++i) {
+            String name = (String) attributeMap.keySet().toArray()[i];
+            if (name.indexOf(':') == -1) {
+                continue;
+            }
+            String componentName = attrToComponent(name);
+            String ns = ProjectHelper.extractUriFromComponentName(componentName);
+            if (componentHelper.getRestrictedDefinitions(
+                    ProjectHelper.nsToComponentName(ns)) == null) {
+                continue;
+            }
+
+            String value = (String) attributeMap.get(name);
+
+            EnableAttribute enable = null;
+            try {
+                enable = (EnableAttribute)
+                    ih.createElement(
+                        owner.getProject(), new EnableAttributeConsumer(),
+                        componentName);
+            } catch (BuildException ex) {
+                throw new BuildException(
+                    "Unsupported attribute " + componentName);
+            }
+            if (enable == null) {
+                continue;
+            }
+            value = owner.getProject().replaceProperties(value); // FixMe: need to make config
+            if (!enable.isEnabled(owner, value)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private String attrToComponent(String a) {
+        // need to remove the prefix
+        int p1 = a.lastIndexOf(':');
+        int p2 = a.lastIndexOf(':', p1 - 1);
+        return a.substring(0, p2) + a.substring(p1);
+    }
+
     /**
      * Sets the creator of the element to be configured
      * used to store the element in the parent.
@@ -177,6 +249,9 @@ public class RuntimeConfigurable impleme
      * @param value the attribute's value.
      */
     public synchronized void setAttribute(String name, String value) {
+        if (name.indexOf(':') != -1) {
+            namespacedAttribute = true;
+        }
         setAttribute(name, (Object) value);
     }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java?rev=1479422&r1=1479421&r2=1479422&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java Sun May  5 23:49:49 2013
@@ -170,6 +170,9 @@ public class UnknownElement extends Task
      *
      */
     public void configure(Object realObject) {
+        if (realObject == null) {
+            return;
+        }
         realThing = realObject;
 
         getWrapper().setProxy(realThing);
@@ -281,10 +284,8 @@ public class UnknownElement extends Task
      */
     public void execute() {
         if (realThing == null) {
-            // plain impossible to get here, maybeConfigure should
-            // have thrown an exception.
-            throw new BuildException("Could not create task of type: "
-                                     + elementName, getLocation());
+            // Got here if the runtimeconfigurable is not enabled.
+            return;
         }
         try {
             if (realThing instanceof Task) {
@@ -346,6 +347,14 @@ public class UnknownElement extends Task
                 RuntimeConfigurable childWrapper = parentWrapper.getChild(i);
                 UnknownElement child = it.next();
                 try {
+                    if (!childWrapper.isEnabled(child)) {
+                        if (ih.supportsNestedElement(
+                                parentUri, ProjectHelper.genComponentName(
+                                    child.getNamespace(), child.getTag()))) {
+                            continue;
+                        }
+                        // fall tru and fail in handlechild (unsupported element)
+                    }
                     if (!handleChild(
                             parentUri, ih, parent, child, childWrapper)) {
                         if (!(parent instanceof TaskContainer)) {
@@ -411,6 +420,9 @@ public class UnknownElement extends Task
      * @return the task or data type represented by the given unknown element.
      */
     protected Object makeObject(UnknownElement ue, RuntimeConfigurable w) {
+        if (!w.isEnabled(ue)) {
+            return null;
+        }
         ComponentHelper helper = ComponentHelper.getComponentHelper(
             getProject());
         String name = ue.getComponentName();

Added: ant/core/trunk/src/main/org/apache/tools/ant/attribute/AttributeNamespace.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/attribute/AttributeNamespace.java?rev=1479422&view=auto
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/attribute/AttributeNamespace.java (added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/attribute/AttributeNamespace.java Sun May  5 23:49:49 2013
@@ -0,0 +1,26 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.tools.ant.attribute;
+
+/**
+ * This class is used to indicate that the xml namespace (uri)
+ * can be used to look for namespace attributes.
+ */
+public final class AttributeNamespace {
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/attribute/AttributeNamespace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/core/trunk/src/main/org/apache/tools/ant/attribute/BaseIfAttribute.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/attribute/BaseIfAttribute.java?rev=1479422&view=auto
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/attribute/BaseIfAttribute.java (added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/attribute/BaseIfAttribute.java Sun May  5 23:49:49 2013
@@ -0,0 +1,85 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.tools.ant.attribute;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.RuntimeConfigurable;
+import org.apache.tools.ant.UnknownElement;
+
+
+/**
+ * An abstract class for if/unless attributes.
+ * This contains a boolean flag to specify whether this is an
+ * if or unless attribute.
+ */
+public abstract class BaseIfAttribute
+    extends ProjectComponent implements EnableAttribute {
+    private boolean positive = true;
+    /**
+     * Set the positive flag.
+     * @param positive the value to use.
+     */
+    protected void setPositive(boolean positive) {
+        this.positive = positive;
+    }
+
+    /**
+     * Get the positive flag.
+     * @return the flag.
+     */
+    protected boolean isPositive() {
+        return positive;
+    }
+
+    /**
+     * convert the result.
+     * @param val the result to convert
+     * @return val if positive or !val if not.
+     */
+    protected boolean convertResult(boolean val) {
+        return positive ? val : !val;
+    }
+
+    /**
+     * Get all the attributes in the ant-attribute:param
+     * namespace and place them in a map.
+     * @param el the element this attribute is in.
+     * @return a map of attributes.
+     */
+    protected Map getParams(UnknownElement el) {
+        Map ret = new HashMap();
+        RuntimeConfigurable rc = el.getWrapper();
+        Map attributes = rc.getAttributeMap(); // This does a copy!
+        for (Iterator i = attributes.entrySet().iterator(); i.hasNext();) {
+            Map.Entry entry = (Map.Entry) i.next();
+            String key = (String) entry.getKey();
+            String value = (String) entry.getValue();
+            if (key.startsWith("ant-attribute:param")) {
+                int pos = key.lastIndexOf(':');
+                ret.put(key.substring(pos + 1),
+                        el.getProject().replaceProperties(value));
+            }
+        }
+        return ret;
+    }
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/attribute/BaseIfAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/core/trunk/src/main/org/apache/tools/ant/attribute/EnableAttribute.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/attribute/EnableAttribute.java?rev=1479422&view=auto
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/attribute/EnableAttribute.java (added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/attribute/EnableAttribute.java Sun May  5 23:49:49 2013
@@ -0,0 +1,34 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.tools.ant.attribute;
+
+import org.apache.tools.ant.UnknownElement;
+
+/**
+ * This interface is used by ant attributes.
+ */
+public interface EnableAttribute {
+    /**
+     * is enabled.
+     * @param el the unknown element this attribute is in.
+     * @param value the value of the attribute.
+     * @return true if the attribute enables the element, false otherwise.
+     */
+    boolean isEnabled(UnknownElement el, String value);
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/attribute/EnableAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfBlankAttribute.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfBlankAttribute.java?rev=1479422&view=auto
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfBlankAttribute.java (added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfBlankAttribute.java Sun May  5 23:49:49 2013
@@ -0,0 +1,38 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.tools.ant.attribute;
+
+import org.apache.tools.ant.UnknownElement;
+
+/**
+ * Check if an attribute is blank or not.
+ */
+public class IfBlankAttribute extends BaseIfAttribute {
+    /** The unless version */
+    public static class Unless extends IfBlankAttribute {
+        { setPositive(false); }
+    }
+    /**
+     * check if the attribute value is blank or not
+     * {@inheritDoc}
+     */
+    public boolean isEnabled(UnknownElement el, String value) {
+        return convertResult((value == null || "".equals(value)));
+    }
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfBlankAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfSetAttribute.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfSetAttribute.java?rev=1479422&view=auto
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfSetAttribute.java (added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfSetAttribute.java Sun May  5 23:49:49 2013
@@ -0,0 +1,38 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.tools.ant.attribute;
+
+import org.apache.tools.ant.UnknownElement;
+
+/**
+ * Check if an attribute value as a property is set or not
+ */
+public class IfSetAttribute extends BaseIfAttribute {
+    /** The unless version */
+    public static class Unless extends IfSetAttribute {
+        { setPositive(false); }
+    }
+    /**
+     * check if the attribute value is blank or not
+     * {@inheritDoc}
+     */
+    public boolean isEnabled(UnknownElement el, String value) {
+        return convertResult(getProject().getProperty(value) != null);
+    }
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfSetAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfTrueAttribute.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfTrueAttribute.java?rev=1479422&view=auto
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfTrueAttribute.java (added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfTrueAttribute.java Sun May  5 23:49:49 2013
@@ -0,0 +1,40 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.tools.ant.attribute;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.UnknownElement;
+
+/**
+ * Check if an attribute value is true or not.
+ */
+public class IfTrueAttribute extends BaseIfAttribute {
+    /** The unless version */
+    public static class Unless extends IfTrueAttribute {
+        { setPositive(false); }
+    }
+
+    /**
+     * check if the attribute value is true or not
+     * {@inheritDoc}
+     */
+    public boolean isEnabled(UnknownElement el, String value) {
+        return convertResult(Project.toBoolean(value));
+    }
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/attribute/IfTrueAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AttributeNamespaceDef.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AttributeNamespaceDef.java?rev=1479422&view=auto
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AttributeNamespaceDef.java (added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AttributeNamespaceDef.java Sun May  5 23:49:49 2013
@@ -0,0 +1,51 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.tools.ant.taskdefs;
+
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.ComponentHelper;
+import org.apache.tools.ant.AntTypeDefinition;
+import org.apache.tools.ant.attribute.AttributeNamespace;
+
+/**
+ * Defintion to allow the uri to be considered for
+ * ant attributes.
+ *
+ * @since Ant 1.8.0
+ */
+public final class AttributeNamespaceDef  extends AntlibDefinition {
+
+    /**
+     * Run the definition.
+     * This registers the xml namespace (uri) as a namepace for
+     * attributes.
+     */
+    public void execute() {
+        String componentName = ProjectHelper.nsToComponentName(
+            getURI());
+        AntTypeDefinition def = new AntTypeDefinition();
+        def.setName(componentName);
+        def.setClassName(AttributeNamespace.class.getName());
+        def.setClass(AttributeNamespace.class);
+        def.setRestrict(true);
+        def.setClassLoader(AttributeNamespace.class.getClassLoader());
+        ComponentHelper.getComponentHelper(getProject())
+            .addDataTypeDefinition(def);
+    }
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AttributeNamespaceDef.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/defaults.properties
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/defaults.properties?rev=1479422&r1=1479421&r2=1479422&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/defaults.properties (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/defaults.properties Sun May  5 23:49:49 2013
@@ -20,6 +20,7 @@ antstructure=org.apache.tools.ant.taskde
 antversion=org.apache.tools.ant.taskdefs.condition.AntVersion
 apply=org.apache.tools.ant.taskdefs.Transform
 apt=org.apache.tools.ant.taskdefs.Apt
+attributenamespacedef=org.apache.tools.ant.taskdefs.AttributeNamespaceDef
 augment=org.apache.tools.ant.taskdefs.AugmentReference
 available=org.apache.tools.ant.taskdefs.Available
 basename=org.apache.tools.ant.taskdefs.Basename

Added: ant/core/trunk/src/tests/antunit/core/ant-attribute-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/core/ant-attribute-test.xml?rev=1479422&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/core/ant-attribute-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/core/ant-attribute-test.xml Sun May  5 23:49:49 2013
@@ -0,0 +1,60 @@
+<?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 name="ant-attribute-test" default="antunit"
+         xmlns:au="antlib:org.apache.ant.antunit"
+         xmlns:if="ant:if"
+         xmlns:unless="ant:unless"
+         >
+
+  <import file="../antunit-base.xml" />
+
+  <target name="test-if-set">
+    <echo message="message1" if:set="not-set"/>
+    <au:assertLogDoesntContain text="message1"/>
+  </target>
+
+  <target name="test-unless-set">
+    <echo message="message2" unless:set="not-set"/>
+    <au:assertLogContains text="message2"/>
+  </target>
+
+  <target name="test-if-true">
+    <property name="sample" value="true"/>
+    <echo message="message3" if:true="${sample}"/>
+    <au:assertLogContains text="message3"/>
+  </target>
+
+  <target name="test-if-true-false">
+    <property name="sample-1" value="false"/>
+    <echo message="message4" if:true="${sample-1}"/>
+    <au:assertLogDoesntContain text="message4"/>
+  </target>
+
+  <target name="test-unless-true-false">
+    <property name="sample-1" value="false"/>
+    <echo message="message5" unless:true="${sample-1}"/>
+    <au:assertLogContains text="message5"/>
+  </target>
+
+  <target name="test-if-blank">
+    <property name="sample-1" value=""/>
+    <echo message="message6" if:blank="${sample-1}"/>
+    <au:assertLogContains text="message6"/>
+  </target>
+
+</project>

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



Mime
View raw message