Search code examples
javaantbootclasspath

Use ant path as property in bootclasspath


In the ant script, I have path set:

<path id="classpath.id">
  <pathelement path="somepath_1" />
  ...
  <pathelement path="somepath_n" />
</path>

So that I use it in java task:

<java ... classpathref="classpath.id">
 ...
</java>

How do I use the classpath.id to set bootclasspath in java ant task similar to:

<java ...>
  <jvmarg value="-Xbootclasspath/a:${myjar.jar}${path.separator}${classpath.id}"/>
</java>

${classpath.id} is not known to the ant at this point.


Solution

  • There's a special syntax for getting the value of something referred to by an Ant reference id. Use ${ant.refid:classpath.id} instead of ${classpath.id}.

    See Getting the value of a Reference with ${ant.refid:} for reference.