[PLUG] zip inside an antfile ... strange

Ted Kubaska tkubaska at charter.net
Wed Jun 6 17:02:16 UTC 2007


Thanks. Why the exec? We never get to write anything from scratch these
days .. this code snippet is from a build environment that contains
hundreds of xml lines and dozens of config files (it actually runs under
CruiseControl and uses Eclipse's antRunner). Using exec has something to
do with retaining file permissions in the zip (maybe). I did think of
using the zip task ... but I wanted to change as little as possible
(also took out the -q to put more info into our log file).

It is working now. I changed some lines in one of the xml files to be 

<exec executable="zip" dir="${assemblyTempDir}/">
  <arg line="-r ${zipargs} '${archiveFullPath}'"/>
  <arg line="${pluginArchivePrefix} -xi
${pluginArchivePrefix}/**/*.jar"/>
</exec>

instead of 

<exec executable="zip" dir="${assemblyTempDir}">
  <arg line="-r -q ${zipargs} '${archiveFullPath}'"/>
  <arg line="${pluginArchivePrefix}/*.jar"/>
</exec>

This was a "seat of the pants" change. I don't know why it works. It's
not how I interpret the docs. I'd like eventually to understand what's
happening, and it's something I'll monitor. But at least the builds are
working now.

 -ted

On Wed, 2007-06-06 at 11:46 -0400, Alex LeDonne wrote:

> On 6/5/07, tkubaska at charter.net <tkubaska at charter.net> wrote:
> > I am very confused. I'm looking at a zip inside an antfile that doesn't work. I have extracted asimple example that illustrates the issue I am having. Can someone take a
> > look at what follows? ... it's not long to read and I've tried all my tricks ... it seems very strange to me.
> >
> > 1.
> > Note that there are jar files present in the following directory
> > hierarchy.
> > ted at halibut:/opt/build001.ecf/ecf.build/tmp$ ls -R
> > .:
> > customTargets.xml  eclipse
> > ./eclipse:
> > plugins
> > ./eclipse/plugins:
> > org.apache.commons.codec_1.2.0.jar
> > org.apache.commons.httpclient_3.0.1.v200703281019.jar
> > org.apache.commons.logging_1.0.4.v200701082340.jar
> >
> > 2.
> > Try this simple ant file as follows: (Note that I am running in tmp and
> > eclipse/plugins are local to me.)
> > ted at halibut:/opt/build001.ecf/ecf.build/tmp$ cat customTargets.xml
> > <project default="main">
> >  <target name="main">
> >     <exec executable="zip" >
> >        <arg line="-r foo.zip eclipse/plugins/*.jar" />
> >     </exec>
> >  </target>
> > </project>
> >
> > 3.
> > It doesn't work. (BTW, docs tell me it should.) Not matched? -- the files
> > are really there as shown above.
> > ted at halibut:/opt/build001.ecf/ecf.build/tmp$ ant -f customTargets.xml
> > Buildfile: customTargets.xml
> >
> > main:
> >      [exec]     zip warning: name not matched: eclipse/plugins/*.jar
> >      [exec]
> >      [exec] zip error: Nothing to do! (try: zip -r foo.zip . -i
> > eclipse/plugins/*.jar)
> >      [exec] Result: 12
> >
> > BUILD SUCCESSFUL
> > Total time: 0 seconds
> > ted at halibut:/opt/build001.ecf/ecf.build/tmp$
> >
> > 4.
> > Do it from the command line (not thru an antfile and it works).
> > ted at halibut:/opt/build001.ecf/ecf.build/tmp$ zip -r foo.zip
> > eclipse/plugins/*.jar
> >   adding: eclipse/plugins/org.apache.commons.codec_1.2.0.jar (deflated
> > 13%)
> >   adding:
> > eclipse/plugins/org.apache.commons.httpclient_3.0.1.v200703281019.jar
> > (deflated 9%)
> >   adding:
> > eclipse/plugins/org.apache.commons.logging_1.0.4.v200701082340.jar
> > (deflated 10%)
> > ted at halibut:/opt/build001.ecf/ecf.build/tmp$
> >
> > 5.
> > The antfile will work if I don't use the *. That is, if I explicitly
> > type out the jar file name without a wildcard. I have tried various
> > schemes for escaping the * ... such as \*, **/*, **/\*, etc.
> >
> > I've put in a bunch of time on this ... I'm stuck.
> >  -ted
> 
> I haven't looked at ant in a while, but I have a question and a guess.
> 
> - Why not use a <zip> task instead of an exec task with zip? Then you
> can define a fileset or zipfileset the way you expect
> 
> - Guess: When you use exec, ant is forking the executable directly, so
> there's no shell executed to interpret the * as a fileglob. Instead,
> it's being passed as a literal splat character.
> 
> Good luck!
> 
> -Alex
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug



More information about the PLUG mailing list