Hi, all.

After looking at the various solutions for including a list of zips, I 
am looking at modifying the zip task for my own needs.  I believe these 
mods are of interest to anyone who needs to merge multiple jars into a 
final result jar, and I would like to contribute the results so others 
do not have to go through the hoops I did.  (Always assuming I get it 
finished.)

The goal:

By setting a property or known set of properties, I can include an 
arbitrary number of zip files into my jar without having to make a 
special target that knows how many zips it has to merge, and without 
having the overhead of a runtime for-each or antcall

The proposed implementation:

I see two ways to do this.  The first is not terribly controversial.  If 
zipfileset had an attribute which caused it to fail silently when the 
src file was not found, then I could make a whole list of properties 
each containing one zip to include.  I propose the attribute name 
"silent-fail-on-missing-source".  If there is one the committers like 
better, I am open to suggestions.  It does not imply any kind of 
for-each action, and the default behavior is exactly as per now.

The second is either making the zip task take a "zipfilelist" consisting 
of a comma separated list of files, or modifying a zipfileset to 
understand that format.  Each entry is expanded as the src of a zip 
fileset, producing one zipfileset per item in the input list.

This is exactly the behavior one gets from javac using the includes and 
excludes elements.  The problem here is that we have already chosen to 
use these elements for the contents of the zip files.

I would prefer a "zipfilelist" that turns into seperate zipfilesets, as 
then it is clear what we intend.  This differs from a for-each, in that 
we are merely specifying a list of files, and only one task does the 
work.  ALl we are doing is adding the means to specify a list for the 
zip/jar tasks, much like one can already do for a is not quite the same 
as a for-each, which the committers are philosophically opposed to, in 
that many tasks have such a beast.  Were we able to send a directory to 
zipfileset as the src, and then to apply include and exclude to the 
_zipfiles_, rather than the contents, this would fit right in.  As it 
is, we need a somewhat more limited approach.

Use case for number 1:

<property name="jar.extra.zip1" value="first.jar"/>
<property name="jar.extra.zip2" value="second.jar"/>
<property name="jar.extra.zip3" value=""/>

<jar
   jarfile="product.jar"
   basedir="${compile.classes}"
   <zipfileset src="${jar.extra.zip1}" silent-on-missing-source="true"/>
   <zipfileset src="${jar.extra.zip2}" silent-on-missing-source="true"/>
   <zipfileset src="${jar.extra.zip3}" silent-on-missing-source="true"/>
</jar>

Use case for number 2:

<property name="jar.extra.zips" value="first.jar, second.jar"/>

<jar
   jarfile="product.jar"
   basedir="${compile.classes}"
   <zipfilelist src="${jar.extra.zips}" silent-on-missing-source="true"/>
</jar>

Scott


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to