Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<zipfileset> vs. <fileset> in ant

Tags:

ant

The ant build tool provides two different tasks <fileset/> and <zipfileset/>. According to the documentation <zipfileset/> allows us to extract files from a .zip file if we use src attribute.

My question is if we are using dir attribute to select files then what is the difference between the two, <zipfileset/> and <fileset/>.

e.g.

                <zipfileset dir="conf/Gateway>
                <include name="jndi.properties" />
                </zipfileset>

                                 and

                <fileset dir="conf/Gateway>
                <include name="jndi.properties" />
                </fileset>
like image 701
Shurmajee Avatar asked Jan 23 '13 06:01

Shurmajee


1 Answers

One useful difference between the two tasks if you're building an archive (a ZIP or WAR or JAR for example) is that a zipfileset has a prefix attribute you can use to relocate the given files at a different folder in the archive. For example, if the following is included in a bigger set of fileset and zipfileset elements:

<zipfileset dir="conf/Gateway" prefix="properties">
    <include name="jndi.properties" />
</zipfileset>

then the file conf/Gateway/jndi.properties will actually be included in the output as conf/Gateway/properties/jndi.properties. You can achieve the same end in other ways, but this is occasionally useful.

Otherwise, just use the task that seems most appropriate for the task at hand.

like image 175
Eddie Avatar answered Nov 15 '22 05:11

Eddie