Java Tutorial/Ant/Fileset Pattern
Содержание
- 1 class file set with root
- 2 Create a class file set
- 3 Define a pattern set
- 4 Dir set
- 5 fileset based on date
- 6 fileset based on folder and file name
- 7 fileset with containsregexp
- 8 fileset with depth
- 9 fileset with exclude
- 10 fileset with include and contians
- 11 fileset with patternset and different
- 12 fileset with present
- 13 fileset with selector
- 14 fileset with size check
- 15 fileset with two containsregexp
- 16 flatten a filelist
- 17 Include files into a file set
- 18 Pattern set with one star
- 19 Set defaultexcludes to "no"
class file set with root
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<classfileset id="zip.classes.id" dir="${build.stand-alone}">
<root classname="org.jexp.client.Client"/>
</classfileset>
</project>
Create a class file set
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<classfileset id="zip.classes.id" dir="${build.stand-alone}">
<rootfileset dir="${build.stand-alone}"
includes="org/jexp/**/*.class"/>
</classfileset>
</project>
Define a pattern set
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<patternset id="src.files">
<include name="${src}/**"/>
<include name="build.*"/>
</patternset>
</project>
Dir set
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<dirset dir="." id="implicit">
<include name="lib/**"/>
</dirset>
</project>
fileset based on date
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="${src.shared}/docs">
<include name="*.html"/>
<date datetime="01/02/2005" pattern="DD/MM/YYYY"/>
</fileset>
</project>
fileset based on folder and file name
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="${build}/build-mysql-jdbc">
<filename name="mysql-connector*/*.jar" negate="true"/>
</fileset>
</project>
fileset with containsregexp
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset id="javadoc" dir="${src}">
<include name="shared/**"/>
<include name="stand-alone/**"/>
<include name="web/java/**"/>
<containsregexp expression="Licensed under the Apache Licen[sc]e"/>
</fileset>
</project>
fileset with depth
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="${docs.all.dir}">
<patternset refid="docs.all"/>
<depth max="${user.depth}"/>
</fileset>
</project>
fileset with exclude
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset id="javadoc" dir="${src}">
<exclude name="*/conf/**"/>
<exclude name="*/docs/*"/>
<include name="shared/**"/>
<include name="stand-alone/**"/>
<include name="web/java/**"/>
<depend targetdir="${docs}/api"/>
</fileset>
</project>
fileset with include and contians
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset id="javadoc" dir="${src}">
<include name="shared/**"/>
<include name="stand-alone/**"/>
<include name="web/java/**"/>
<contains text="Licensed under the Apache License"/>
</fileset>
</project>
fileset with patternset and different
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="${docs.all.dir}">
<patternset refid="docs.all"/>
<different targetdir="${docs}/api" ignoreFileTimes="false"/>
</fileset>
</project>
fileset with present
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="${docs.all.dir}">
<patternset refid="docs.all"/>
<present targetdir="${docs}/api" present="srconly"/>
</fileset>
</project>
fileset with selector
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir=".">
<selector if="two.stars">
<filename name="lib/**"/>
</selector>
</fileset>
</project>
fileset with size check
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="${httpunit.home}/jars">
<include name="*.jar"/>
<exclude name="junit.jar"/>
<size value="1" units="Gi" when="less"/>
</fileset>
</project>
fileset with two containsregexp
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset id="javadoc" dir="${src}">
<include name="shared/**"/>
<include name="stand-alone/**"/>
<include name="web/java/**"/>
<none>
<containsregexp expression="Licensed under the Apache Licen[sc]e"/>
<containsregexp expression="GNU GENERAL PUBLIC LICEN[SC]E"/>
</none>
</fileset>
</project>
flatten a filelist
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<filelist dir="lib/java" files="One.java"/>
<filelist dir="lib/java">
<file name="One.java"/>
</filelist>
</project>
Include files into a file set
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="${build}/build-mysql-jdbc">
<include name="mysql-connector*/*.jar"/>
</fileset>
</project>
Pattern set with one star
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<patternset id="pattern.id.one.star">
<include name="lib/*"/>
</patternset>
</project>
Set defaultexcludes to "no"
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="." defaultexcludes="no">
<include name="lib/java/*.java?"/>
</fileset>
</project>