ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Ferguson <>
Subject Re: JLink vs. Jar
Date Tue, 02 Jan 2001 18:27:44 GMT
Hi.  Comments in line.

Rosen, Alex wrote:

> I agree. We were thinking about adding similar functionality. It's confusing to
> have both <jar> and <jlink> tasks that do similar but different things -
> agree that the <jlink> functionality should be moved into <jar>. Stefan seemed
> to disagree though:
> Stefan Bodewig <> 2000-09-11:
>> We shouldn't try to duplicate
>> this functionality (adding files to existing .jar files for example)
>> in <jar> IMHO. Let's keep <jar> the simple solution that fits most
>> situations and point people to <jlink> in the more difficult ones.
> To me, this is confusing, and it also presents problems if people want to use
> different features at once. E.g. what if you want to use the <war> task but
> also want the merging capabilities of <jlink>? And maybe some other feature of
> another <jar> derivative in the future? You can't do that unless the common
> functionality is in the base <jar> task. Stefan, what do you think?


> On the other hand, you do have the problem of how exactly to combine these
> pieces of functionality. E.g the <jar> task now can have <prefixedfileset>
> children, which are just like <filesets> except that then can specify where in
> the target JAR the files should go. (Kind of the complement of your <jarfilter>
> functionality.) The question is, can I suck out the contents of a JAR file with
> <jarfilter> and place them in a particular subdirectory of the target JAR? If
> so, do we need <fileset> <prefixedfileset> <jarfilter> and <prefixedjarfilter>?
> The list could expand exponentially. That's why I preferred having just
> <fileset>, which would have the special property that it can have certain extra
> attributes in certain cases. Then, you could just use <fileset
> sourcejar="blah.jar" prefix="web-inf/classes" />.

Filtered jar files don't make sense in many (most?) contexts where
filesets are used (e.g. Delete, Copy, Chmod, Move, ExecOn, Ftp, etc),
so I am a little uncomfortable folding such specialized functionality
into something as generic as FileSets.  Also, I think it may not be
a comfortable fit; I've encountered code that assumes that the
items in a FileSet are individual files on the file system which
is not the case with Jar entries.

Regarding a prefix for the entries, I think it would be appropriate
to add a prefix attribute to jarfilter.  I agree that it would be
bad to add a whole new type for this.

> On a different note, the doc says that "jlink ignores META-INF directories in
> mergefiles. Users should supply their own manifest information for the output
> file." How do your changes handle this? Should we leave it up to the user to
> exclude META-INF, or will this be error-prone? Do we need something ugly like
> exclude-meta-inf="false"?

We should not exclude META-INF files altogether.  I think the
right thing to do is to keep track of which files are added to
the META-INF directory, and ignore duplicates.  Arguably, this
is true for all files in the Jar, not just files in the META-INF

> Alex
>> -----Original Message-----
>> From: Don Ferguson []
>> Sent: Friday, December 29, 2000 6:49 PM
>> To:
>> Subject: JLink vs. Jar
>> I have recently begun exploring ant, and have found the JLink
>> task to be
>> insufficient for my needs, and also, not consistent with other file
>> based ant tasks.  Specifically, JLink does not provide a mechanism for
>> selecting a subset of a jar file via includes/excludes.  It also seems
>> to me that there is too much overlap in the functionality provided by
>> Jar and JLink, so in my copy of the sources, I have modified the Jar
>> task to subsume the capabilities of JLink by addition of a new data
>> type: JarFilter.  The Jar task can include both FileSets and
>> JarFilters.  A JarFilter extracts a subset of files from the jar using
>> the same matching rules as FileSets, and includes these files in the
>> output jar.  For example, the following would create "myant.jar",
>> including my ant classes with the standard ant.jar, but
>> excluding JLink:
>> <?xml version="1.0"?>
>> <project name="JarExample" default="main" basedir=".">
>>     <target name="main">
>>       <jar jarfile="myant.jar">
>>         <fileset dir="/home/don/classes"
>>               includes="weblogic/ant/"
>>         />
>>         <jarfilter jarfile="/ant/lib/ant.jar"
>>                       includes="org/apache/"
>> excludes="org/apache/tools/ant/taskdefs/optional/jlink/"
>>         />
>>       </jar>
>>     </target>
>> </project>
>> I think this make the Jar task much more useful, but as I'm
>> new to ant,
>> I'd be curious to hear what others have to say about this approach.
>> Comments?
>>     -Don
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message