Ant-Pathelement with wildcard only only in Javac forked mode
问题描述:
使用Ant时遇到以下问题。Ant-Pathelement with wildcard only only in Javac forked mode
我的Ant脚本片段:
<path id="id.compile.classpath">
<pathelement location="src/compile_lib1/*" />
<pathelement location="src/compile_lib2/*" />
</path>
<javac srcdir="${module.root}/${src.root}" destdir="${swap.target.classes}"
nowarn="${javac.nowarn}" debug="${javac.debug}" fork="${javac.fork}"
classpathref="id.compile.classpath" includeAntRuntime="${javac.includeAntRuntime}">
<include name="**/*.java"/>
</javac>
当设置叉javac任务=”真”,通配符pathelement工作正常,但分叉设置为false时,蚂蚁似乎未能正确解释通配符。 (编译失败,由于类路径错误)。
任何建议
谢谢。
答
不是使用通配符pathelement
,而是使用fileset
并让Ant为您扩展通配符。
<path id="id.compile.classpath">
<fileset dir="src/compile_lib1" includes="*.jar" />
<fileset dir="src/compile_lib2" includes="*.jar" />
</path>
明白,只是想知道为什么不我的情况 – foolhunger 2014-08-27 16:39:49
@foolhunger Java的工作不支持通配符在classpath中,同样没有ANT。请参阅:http://ant.apache.org/manual/using.html#path – 2014-08-27 16:58:43
@foolhunger关于[有关类路径的Oracle文档]中的通配符部分(http://docs.oracle.com/javase/7/docs /technotes/tools/solaris/classpath.html)表示:“扩展通配符在调用程序的主要方法之前就已经提前完成了,而不是在类加载过程本身的晚期完成” - 这表明在分叉模式JVM启动器将扩展通配符并将扩展版本的路径传递给编译器类。在非分叉模式下,这种情况不会发生,编译器会看到它不知道如何处理的文字“*”。 – 2014-08-27 17:00:08