I have a scenario where I'm trying to reuse the same build.xml
file across multiple projects. In each case, the finaly target is a dist
that JARs everything up. The only difference is that some of the projects have a src/main/java/META-INF/*
directory, and others don't (and just have a src/main/java/*
directory).
I want to use the Ant-Contrib <if/>
task to optionally define a META-INF/
directory if the build sees a src/main/java/META-INF/*
directory available. So something like this:
<jar jarfile="myapp.jar">
<if>
<available file="src/main/java/META-INF" />
<then>
<!--
Copy everything from src/main/java/META-INF into
the JAR's META-INF directory.
But how?!?
-->
<echo message="I'm trying to copy META-INF!" />
</then>
</if>
</jar>
But I am choking on two things here:
- When I run this target, I get a build exception stating that I can't nest an
<if/>
inside the<jar/>
task; and - I'm not sure how to configure the
<jar/>
task to create aMETA-INF
directory at the root of the classpath, and copy all of thesrc/main/java/META-INF
contents into it.
Any thoughts? Thanks in advance.