'wrong JAR packaging in ant file with zipfileset

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:

enter image description here

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



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sukhbir Dhillon