ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r673467 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/types/resources/selectors/Type.java src/tests/antunit/types/resources/selectors/test.xml
Date Wed, 02 Jul 2008 19:02:52 GMT
Author: mbenson
Date: Wed Jul  2 12:02:51 2008
New Revision: 673467

URL: http://svn.apache.org/viewvc?rev=673467&view=rev
Log:
type any

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/selectors/Type.java
    ant/core/trunk/src/tests/antunit/types/resources/selectors/test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=673467&r1=673466&r2=673467&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Jul  2 12:02:51 2008
@@ -85,7 +85,7 @@
  * There is now a FileProvider interface for resources that act as a source
    of filenames. This should be used by tasks that require resources
    to provide filenames, rather than require that all resources
-   are instances or subclasses of FileResource
+   are instances or subclasses of FileResource.
    Bugzilla report 43348
    
  * Fixcrlf now gives better error messages on bad directory attributes.
@@ -98,6 +98,9 @@
    list of the targets that have been specified on the command line
    (the IDE, an <ant> task ...) when invoking the current project.
 
+ * The <type> resource selector has had an "any" type added for better
+   configurability.
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/selectors/Type.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/selectors/Type.java?rev=673467&r1=673466&r2=673467&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/selectors/Type.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/selectors/Type.java Wed Jul
 2 12:02:51 2008
@@ -29,6 +29,7 @@
 
     private static final String FILE_ATTR = "file";
     private static final String DIR_ATTR = "dir";
+    private static final String ANY_ATTR = "any";
 
     /** Static file type selector. */
     public static final Type FILE = new Type(new FileDir(FILE_ATTR));
@@ -36,11 +37,14 @@
     /** Static dir type selector. */
     public static final Type DIR = new Type(new FileDir(DIR_ATTR));
 
+    /** Static any type selector. Since Ant 1.8. */
+    public static final Type ANY = new Type(new FileDir(ANY_ATTR));
+
     /**
      * Implements the type attribute.
      */
     public static class FileDir extends EnumeratedAttribute {
-        private static final String[] VALUES = new String[] {FILE_ATTR, DIR_ATTR};
+        private static final String[] VALUES = new String[] { FILE_ATTR, DIR_ATTR, ANY_ATTR
};
 
         /**
          * Default constructor.
@@ -99,7 +103,7 @@
             throw new BuildException("The type attribute is required.");
         }
         int i = type.getIndex();
-        return r.isDirectory() ? i == 1 : i == 0;
+        return i == 2 || (r.isDirectory() ? i == 1 : i == 0);
     }
 
 }

Modified: ant/core/trunk/src/tests/antunit/types/resources/selectors/test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/types/resources/selectors/test.xml?rev=673467&r1=673466&r2=673467&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/types/resources/selectors/test.xml (original)
+++ ant/core/trunk/src/tests/antunit/types/resources/selectors/test.xml Wed Jul  2 12:02:51
2008
@@ -15,10 +15,12 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project default="all" xmlns:au="antlib:org.apache.ant.antunit"
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit"
          xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors"
          xmlns:rcmp="antlib:org.apache.tools.ant.types.resources.comparators">
 
+  <import file="../../../antunit-base.xml" />
+
   <available property="jdk1.4+" classname="java.lang.CharSequence"/>  
   <condition property="some.regexp.support">
     <or>
@@ -145,19 +147,36 @@
   <target name="instanceof" depends="instanceoftype,testinstanceofclass" />
 
   <target name="testtype">
+    <resources id="testtype">
+       <file file="${basedir}" />
+       <file file="${ant.file}" />
+       <resource directory="true" />
+       <resource directory="false" />
+    </resources>
     <au:assertTrue>
       <resourcecount when="equal" count="2">
         <restrict>
-          <resources>
-             <file file="${basedir}" />
-             <file file="${ant.file}" />
-             <resource directory="true" />
-             <resource directory="false" />
-          </resources>
+          <resources refid="testtype" />
           <rsel:type type="dir" />
         </restrict>
       </resourcecount>
     </au:assertTrue>
+    <au:assertTrue>
+      <resourcecount when="equal" count="2">
+        <restrict>
+          <resources refid="testtype" />
+          <rsel:type type="file" />
+        </restrict>
+      </resourcecount>
+    </au:assertTrue>
+    <au:assertTrue>
+      <resourcecount when="equal" count="4">
+        <restrict>
+          <resources refid="testtype" />
+          <rsel:type type="any" />
+        </restrict>
+      </resourcecount>
+    </au:assertTrue>
   </target>
 
   <target name="testdate">



Mime
View raw message