[英]How to specify directory or file glob as javac classpath value with Apache Ant?
Is there a way to set the value of the javac
classpath
property in Apache Ant (v1.9.6) so that I don't have to literally specify all the jars that I want to include eg a directory or file glob. 有没有一种方法可以在Apache Ant(v1.9.6)中设置
javac
classpath
属性的值,这样我就不必从字面上指定要包含的所有jar,例如目录或文件glob。
So, if I have something like: 所以,如果我有这样的事情:
<javac classpath="./lib/one.jar":./lib/two.jar:./lib/three.jar..."
...is there anyway to just specify my ./lib
directory once, like the way you can do when you run a java application like: ...无论如何,只需指定一次我的
./lib
目录,就像运行Java应用程序时可以执行的方式:
java -cp ./lib/'*'
I've tried that, and just using ./lib
, or ./lib/*
or ./lib/*.jar
but they don't work. 我已经尝试过了,只是使用
./lib
或./lib/*
或./lib/*.jar
但它们不起作用。
Try putting a <classpath>
element under <javac>
: 尝试将
<classpath>
元素放在<javac>
:
<javac ...>
<classpath>
<fileset dir="lib" includes="*.jar"/>
</classpath>
</javac>
And another solution using a reusable classpath reference: 另一个使用可重用的类路径引用的解决方案:
<path id="compile.path">
<fileset dir="lib" includes="*.jar"/>
</path>
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false" debug="true" classpathref="compile.path"/>
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<path refid="compile.path"/>
<pathelement path="${classes.dir}"/>
</classpath>
..
..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.