Reputation: 7605
I'm encountering a strange issue in an ANT file I use for building a Java app. When generating the jar file, eventually I include resource files (images, fonts and config files) in the JAR using zipfileset, like this:
<zipfileset dir="src/res" prefix="res"/>
<zipfileset dir="src/res/images" prefix="res/images" />
<zipfileset dir="src/res/images/Bubbles" prefix="res/images/Bubbles"/>
<zipfileset dir="src/res/images/Clocks" prefix="res/images/Clocks"/>
<zipfileset dir="src/config" prefix="res/config"/>
<zipfileset dir="src/ontology" prefix="res/ontology"/>
To mantain original structure, that looks like this:
res
|-images
| |-Bubbles
| |-Clocks
|-fonts
|-config
|-ontology
Within the JAR, I'm using the prefix parameter in zipfileset. I'm getting duplicated images in res/images and triple images (3 copies of the same image) in any of the res/images/Bubbles and res/images/Clocks folders, which, in the other hand, are 2 and 3 depth levels respectively. res/config and res/ontology are correct, no duplicated files there...a screenshot to see what I mean:
I forgot to mention, but obviously, I only have one instance of each image in every folder. Any ideas what is causing this behaviour?
Regards, Alex
Upvotes: 2
Views: 599
Reputation: 11
You can use the following attribute to include the whole path without hardcoding each sub-directory.
includes="*/.*"
<zipfileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/>
In above example, I'm including *.html recursively.
Sukhbir Dhillon Addteq
Upvotes: 1
Reputation: 12243
ant
actually does exactly what you told it do. You told him to:
src/res
and to map them to res
.src/res/images
and to map them to res/images
src/res/images/Bubbles
and to them under res/images/Bubbles
Now let's assume that you have a src/res/images/Bubbles/activity_bubble_orange.png
files. That file is contained in the first zipfileset, the second zipfileset and the third zipfileset. Ergo it will be packed three times.
To do what you want you need to do a single <zipfileset dir="src/res" prefix="res" />
but filter the contents using includes/excludes filters.
See here: http://ant.apache.org/manual/Types/zipfileset.html where it say that is a type of fileset. and here: http://ant.apache.org/manual/Types/fileset.html to see how you specify includes/excludes filter for a fileset.
Upvotes: 4