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>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With