我有以下ant文件,
<project>
<path id="build-classpath">
<fileset dir="/opt/apache-tomcat-7.0.53/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="../../lib">
<include name="*.jar"/>
</fileset>
<fileset dir="../../bin">
<include name="*.jar"/>
</fileset>
</path>
<target name="compile">
<mkdir dir="classes"/>
<mkdir dir="bin"/>
<javac srcdir="src/" destdir="classes" includeantruntime="false">
<exclude name="/src/web/DaemonSocket.java"/>
<classpath refid="build-classpath"/>
</javac>
<javac srcdir="src/" destdir="bin" includeantruntime="false">
<classpath refid="build-classpath"/>
</javac>
</target>
<target name="clean">
<delete dir="classes"/>
<delete dir="bin"/>
</target>
</project>
在包含代码的排除行
<javac srcdir="src/" destdir="classes" includeantruntime="false">
<exclude name="/src/web/DaemonSocket.java"/>
<classpath refid="build-classpath"/>
</javac>
我希望文件DaemonSocket.java
不能编译到classes
文件夹中。但是,每次运行ant compile
时,DaemonSocket.java
文件都会编译到classes
和bin
文件夹中。为什么exclude
在这种情况下不起作用?
答案 0 :(得分:4)
尝试使用通配符:
<javac srcdir="src/" destdir="classes" includeantruntime="false">
<exclude name="**/DaemonSocket.java"/> <!--You should use relative path here /src/ should be removed if you dont want to use wildcard-->
<classpath refid="build-classpath"/>
</javac>