Here's a somewhat cruel way of doing it through script
with javascript
language in Ant:
<scriptdef name="getfilenamesfromzipfile" language="javascript">
<attribute name="zipfile" />
<attribute name="property" />
<![CDATA[
importClass(java.util.zip.ZipInputStream);
importClass(java.io.FileInputStream);
importClass(java.util.zip.ZipEntry);
importClass(java.lang.System);
file_name = attributes.get("zipfile");
property_to_set = attributes.get("property");
var stream = new ZipInputStream(new FileInputStream(file_name));
try {
var entry;
var list;
while ((entry = stream.getNextEntry()) != null) {
if (!entry.isDirectory()) {
list = list + entry.toString() + "\n";
}
}
project.setNewProperty(property_to_set, list);
} finally {
stream.close();
}
]]>
</scriptdef>
Which then can be called in a <target>
:
<target name="testzipfile">
<getfilenamesfromzipfile
zipfile="My.zip"
property="file.names.from.zip.file" />
<echo>List of files: ${file.name.from.zip.file}.</echo>
</target>
Any better solution is welcome.