I would like to list the entries of a zip file (ear, war) using ANT. Within my ear, war, jar artifacts I keep the build number in META-INF/MANIFEST.MF file. I would like to create an ANT script to list all the artifacts and their respective build number, so I can recognize artifacts which do not belong to the top artifact build number.
Asked
Active
Viewed 911 times
1
-
Seems like the unzip task would help you, but it might actually be less hassle to write your own Ant task that grabs MANIFEST.MF from the archives in memory and prints out the relevant line. – Nate May 30 '11 at 02:22
-
Seems like the only way to go is using Groovy script in ANT... – erezul May 31 '11 at 03:05
1 Answers
1
After long investigation... groovy task seems like the best way. use Groovy ANT Task to integrate a groovy script into your ANT build. in groovy it's easy to traverse file system and also zip files. it can also access the hosting ANT project through ant binding (AntBuilder).
NOTE: it's advised to use JarInputStream to travers zip files, as it can loop on all entries, and it can get the Manifest if required. To traverse an internal jar file (say jar within a war, or war within an ear), use the read() method to read the current entry into a new JarInputStream object.

erezul
- 527
- 2
- 8
- 19
-
You can also use JavaScript, or any other JSR-223 language, using the Ant [script](https://ant.apache.org/manual/Tasks/script.html) task. – Michael Ekstrand Jul 10 '12 at 03:03