How to jar java source files from different (sub) directories?
Consider the following directory structure:
./source/com/mypackage/../A.java
./extensions/extension1/source/com/mypackage/../T.java
./extensions/extension2/source/com/mypackage/../U.java
...
./extensions/extensionN/source/com/mypackage/../Z.java
I want to create a source jar with the following content:
com/mypackage/../A.java
com/mypackage/../T.java
com/mypackage/../U.java
...
com/mypackage/../Z.java
I know I can use a set of files for each source directory. But is there a simple solution using ANT without having to explicitly reference all extensions?
+2
a source to share
1 answer
How do I flatten all the files to be included in the archive into one directory structure and then archive there?
Use regexpmapper to do anti-aliasing while copying, something like this:
<delete dir="merged" />
<mkdir dir="merged" />
<copy todir="${basedir}/merged">
<fileset dir="${basedir}">
<include name="source/**"/>
<include name="extension*/**"/>
</fileset>
<regexpmapper from=".*source/(.*)" to="\1" />
</copy>
<jar destfile="mypackage.jar" filesonly="yes">
<fileset dir="merged">
<include name="**" />
</fileset>
</jar>
+1
a source to share