Since my ant file is quite complex, I want to modularize my classpath-elements.
Currently, I use refid
in the following way:
<path id="compile.classpath">
<pathelement path="foo"/>
<!-- ... -->
</path>
<path id="test.classpath">
<path refid="compile.classpath"/>
<pathelement path="bar"/>
<!-- ... -->
</path>
<!-- ... -->
<javac>
<classpath refid="compile.classpath"/>
</javac>
<junit>
<!-- ... -->
<classpath>
<path refid="test.classpath"/>
<path path="bazz"/>
</classpath>
</junit>
<!-- ... -->
Is this a sensible approach? Or is there a better one?
Is it ok to use a path-id (compile.classpath
) for a classpath-refid (in <javac>
)? (It currently works, but refid
does require the elements to be of the same type. Since path
and classpath
are both path-like structures, are they of the same type?)
I successfully used this approach at a previous job and it was really the only way I could keep everything sane.
I eventually took things a step further an put all my third-party library definitions in a separate ext-libs.xml
file since several of them were multi-jar libraries and making sure I had all of them contained in my final war files was getting to be a giant hassle. That way, in my main build.xml
(and others) I could refer to, say, lib.jaxb
and not have to worry that I'd updated the version numbers in the files names everywhere.
You've already figured out the trick of extending your compile classpath to make your test classpath, so you're on the right track.
In short, press on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With