<zipfileset> vs. <fileset> in 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 the src attribute.

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

eg.

  <zipfileset dir="conf/Gateway> <include name="jndi.properties" /> </zipfileset> and <fileset dir="conf/Gateway> <include name="jndi.properties" /> </fileset> 
+6
source share
2 answers

One useful difference between the two tasks, if you are building an archive (e.g. ZIP or WAR or JAR), is that zipfileset has a prefix attribute that you can use to move these files to another folder in the archive. For example, if the following is included in a larger set of fileset and zipfileset elements:

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

then the conf/Gateway/jndi.properties will actually be included in the result as conf/Gateway/properties/jndi.properties . You can achieve the same goal in other ways, but it is sometimes useful.

Otherwise, just use the task that is most suitable for this task.

+2
source

After reading the manual: It is clear that zipfileset takes an argument of the src attribute and then uses it as a dir.

quote from the manual

src can be used instead of the dir attribute to indicate a zip file whose contents will be extracted and included in the archive.

0
source

All Articles