git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@673467 13f79535-47bb-0310-9956-ffa450edef68master
@@ -85,7 +85,7 @@ Other changes: | |||||
* There is now a FileProvider interface for resources that act as a source | * There is now a FileProvider interface for resources that act as a source | ||||
of filenames. This should be used by tasks that require resources | of filenames. This should be used by tasks that require resources | ||||
to provide filenames, rather than require that all 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 | Bugzilla report 43348 | ||||
* Fixcrlf now gives better error messages on bad directory attributes. | * Fixcrlf now gives better error messages on bad directory attributes. | ||||
@@ -98,6 +98,9 @@ Other changes: | |||||
list of the targets that have been specified on the command line | list of the targets that have been specified on the command line | ||||
(the IDE, an <ant> task ...) when invoking the current project. | (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 | Changes from Ant 1.7.0 TO Ant 1.7.1 | ||||
============================================= | ============================================= | ||||
@@ -29,6 +29,7 @@ public class Type implements ResourceSelector { | |||||
private static final String FILE_ATTR = "file"; | private static final String FILE_ATTR = "file"; | ||||
private static final String DIR_ATTR = "dir"; | private static final String DIR_ATTR = "dir"; | ||||
private static final String ANY_ATTR = "any"; | |||||
/** Static file type selector. */ | /** Static file type selector. */ | ||||
public static final Type FILE = new Type(new FileDir(FILE_ATTR)); | public static final Type FILE = new Type(new FileDir(FILE_ATTR)); | ||||
@@ -36,11 +37,14 @@ public class Type implements ResourceSelector { | |||||
/** Static dir type selector. */ | /** Static dir type selector. */ | ||||
public static final Type DIR = new Type(new FileDir(DIR_ATTR)); | 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. | * Implements the type attribute. | ||||
*/ | */ | ||||
public static class FileDir extends EnumeratedAttribute { | 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. | * Default constructor. | ||||
@@ -99,7 +103,7 @@ public class Type implements ResourceSelector { | |||||
throw new BuildException("The type attribute is required."); | throw new BuildException("The type attribute is required."); | ||||
} | } | ||||
int i = type.getIndex(); | int i = type.getIndex(); | ||||
return r.isDirectory() ? i == 1 : i == 0; | |||||
return i == 2 || (r.isDirectory() ? i == 1 : i == 0); | |||||
} | } | ||||
} | } |
@@ -15,10 +15,12 @@ | |||||
See the License for the specific language governing permissions and | See the License for the specific language governing permissions and | ||||
limitations under the License. | 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:rsel="antlib:org.apache.tools.ant.types.resources.selectors" | ||||
xmlns:rcmp="antlib:org.apache.tools.ant.types.resources.comparators"> | xmlns:rcmp="antlib:org.apache.tools.ant.types.resources.comparators"> | ||||
<import file="../../../antunit-base.xml" /> | |||||
<available property="jdk1.4+" classname="java.lang.CharSequence"/> | <available property="jdk1.4+" classname="java.lang.CharSequence"/> | ||||
<condition property="some.regexp.support"> | <condition property="some.regexp.support"> | ||||
<or> | <or> | ||||
@@ -145,19 +147,36 @@ | |||||
<target name="instanceof" depends="instanceoftype,testinstanceofclass" /> | <target name="instanceof" depends="instanceoftype,testinstanceofclass" /> | ||||
<target name="testtype"> | <target name="testtype"> | ||||
<resources id="testtype"> | |||||
<file file="${basedir}" /> | |||||
<file file="${ant.file}" /> | |||||
<resource directory="true" /> | |||||
<resource directory="false" /> | |||||
</resources> | |||||
<au:assertTrue> | <au:assertTrue> | ||||
<resourcecount when="equal" count="2"> | <resourcecount when="equal" count="2"> | ||||
<restrict> | <restrict> | ||||
<resources> | |||||
<file file="${basedir}" /> | |||||
<file file="${ant.file}" /> | |||||
<resource directory="true" /> | |||||
<resource directory="false" /> | |||||
</resources> | |||||
<resources refid="testtype" /> | |||||
<rsel:type type="dir" /> | <rsel:type type="dir" /> | ||||
</restrict> | </restrict> | ||||
</resourcecount> | </resourcecount> | ||||
</au:assertTrue> | </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> | ||||
<target name="testdate"> | <target name="testdate"> | ||||