Jar with includes and excludes
<?xml version="1.0"?>
<project name="JAR Demos" default="jar1" basedir=".">
<property name="dir.src" value="src"/>
<property name="dir.build" value="build"/>
<property name="dir.dist" value="dist"/>
<!-- Creates the output directories -->
<target name="prepare">
<mkdir dir="${dir.build}"/>
<mkdir dir="${dir.dist}"/>
</target>
<target name="clean"
description="Remove all generated files.">
<delete dir="${dir.build}"/>
<delete dir="${dir.dist}"/>
</target>
<target name="compile" depends="prepare"
description="Compile all source code.">
<javac srcdir="${dir.src}" destdir="${dir.build}"/>
</target>
<target name="jar1" depends="compile"
description="Basic jar task demo">
<jar jarfile="${dir.dist}/java2s.jar" basedir="${dir.build}"/>
</target>
<target name="jar2" depends="compile"
description="Shows includes and excludes">
<jar jarfile="${dir.dist}/java2s.jar"
basedir="${dir.build}"
includes="**/*.class"
excludes="**/UnitTest*.class"/>
</target>
<target name="jar3" depends="compile"
description="Same as jar2, but uses filesets">
<jar jarfile="${dir.dist}/java2s.jar">
<fileset dir="${dir.build}"
includes="**/*.class"
excludes="**/UnitTest*.class"/>
<fileset dir="${dir.src}"
includes="**/*.properties"/>
</jar>
</target>
</project>
Related examples in the same category