I have a fairly simple ant script that is running my dependencies I'm importing into the class I need to compile using Ant. The excludes doesn't seem to be right.
<property name="dir.src" location="src"/>
<property name="dir.org" location="src\org"/>
<target name="compile" description="compile the source">
<mkdir dir="build"/>
<!-- Compile the java code from ${src} into ${build} -->
<javac listfiles="true" includeantruntime="false" srcdir="${dir.src}" classpath="${dir.src}" destdir="${build} debug="on" >
<include name="src/TaskJob.java" />
<exclude name="${dir.org}" />
</javac>
</target>
The compile runs 1900 java files with
Directory----
---------build.xml
---------+src
-------------+org
-------------TaskJob.java
---------.git
I'm also trying
<dirset id="dirset" dir="${dir.src}">
<include name="src/**.java"/>
<exclude name="src/org/**"/>
</dirset>
and then using a filename:
<javac exclude="dirset" srcdir="${dir.src} destdir="classes" debug="on" >
<filename name="${dir.src}\TaskJob.java"/>
</javac>
Feedback appreciated.
Your script has the following...
<property name="dir.src" location="src"/>
<property name="dir.org" location="src\org"/>
...and the following...
<javac ... srcdir="${dir.src}" ...>
<include name="src/TaskJob.java" />
<exclude name="${dir.org}" />
</javac>
Replacing the properties with their actual values would give the following...
<javac ... srcdir="src" ...>
<include name="src/TaskJob.java" />
<exclude name="src\org" />
</javac>
src
appears in both srcdir
and <include>
. The <include>
would match the following TaskJob.java if it existed in your scenario...
Directory----
---------build.xml
---------src
-------------src
-----------------org
-------------TaskJob.java
Notice how there is a src
subdirectory under another src
directory.
So, what you want is the following...
<javac ... srcdir="src" ...>
<include name="TaskJob.java" />
</javac>
There is no need for an <exclude>
element. Just the <include>
is necessary.
If you want to exclude all java files under org
directory.
<javac listfiles="true" includeantruntime="false" srcdir="${dir.src}" classpath="${dir.src}" destdir="${build} debug="on" >
<exclude name="org/**" />
<include name="src/TaskJob.java" />
</javac>
For more detail and example, you can read the document of FileSet .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.