Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant - Pathelement with wildcard only works in Javac forked mode

Tags:

java

ant

I encountered below issue when using Ant.

My ANT script snippets:

<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>

When set fork=”true” in javac task, the wildcard pathelement works fine, but when forked is set to false, Ant seems failed to interpret wildcard correctly. (compilation failed, due to classpath error).

Any suggestions
Thanks.

like image 240
foolhunger Avatar asked Oct 28 '25 06:10

foolhunger


1 Answers

Instead of using a wildcard pathelement, use a fileset and let Ant expand out the wildcard for you.

<path id="id.compile.classpath">
  <fileset dir="src/compile_lib1" includes="*.jar" />
  <fileset dir="src/compile_lib2" includes="*.jar" />
</path>
like image 59
Ian Roberts Avatar answered Oct 29 '25 20:10

Ian Roberts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!