ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steele, Richard" <>
Subject Using <concat> as a resource collection in <zip>
Date Fri, 01 Apr 2011 11:43:13 GMT
I'm trying to use <concat> as a resource collection in a <zip> and found
that it doesn't work so well.

First, an example:

<zip destfile="target/">
      <fileset file="CHANGES.txt" />

This creates a zip file with multiple entries named "concat (C:", not a
single entry containing the CHANGES.txt file.

(The reason I'm playing with <concat> as a resource collection for a <zip>:
I want to include all the files in my distribution verbatim, except the
CHANGES.txt file I want to do property substitution.  Since <concat> allows
a <filterchain> I thought this would be a good way to do it.  The snippet
above is a stripped-down, simplified example that reproduces the problem.)

I looked at the source for <zip> and <concat> and figured out why: the
implementation of <concat> (as a ResourceCollection) returns a single,
hard-coded name for the Resource it contains:

public String getName() {
   return "concat (" + String.valueOf(c) + ")";

I can't imagine such a construction is ever useful.

I was able to work around this issue by using a <mappedresources>:

<zip destfile="target/">
         <fileset file="CHANGES.txt" />
      <mergemapper to="CHANGES.txt" />

but this is IMHO clunky and not terribly obvious.

I propose two changes:

1. Allow the resource name to be specified when <concat> is used as a
ResourceCollection; e.g., something like

<zip destfile="target/">
   <concat name="CHANGES.txt">
      <fileset file="CHANGES.txt" />

It would be helpful if getName() could automatically do this if <concat>
itself contains a single Resource so it doesn't have to be specified as an

2. Throw a BuildException if getName() is called and no name is available.
(In other words, fail fast rather than produce something useless.)



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message