You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jason Pringle <Ja...@captura.com> on 2001/03/08 02:50:55 UTC

and problems...

Ok, I'm obviously not understanding how <fileset> creates its list of files,
because the three (seemingly equivalent) task definitions don't all work.
(I know I can do the jar task simpler than below, but for the full version I
use multiple <fileset> nested attributes.  It just happens that it chokes on
the following one.)  The error I'm getting from <jar> is below (a duplicate
entry exception).  Is there a (simple) way to have the <fileset> output to
the screen?  Using -verbose or -debug doesn't work...evidently the task
fails before the <fileset> contents is logged. 

C:\dev\v50\build.xml:132: Problem creating jar: duplicate entry:
com/captura/system/common/crypto/Decryption.class
--- Nested Exception ---
java.util.zip.ZipException: duplicate entry:
com/foo/system/common/crypto/Bar.class
        at
java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:165)
        at org.apache.tools.ant.taskdefs.Zip.zipFile(Zip.java:455)
        at org.apache.tools.ant.taskdefs.Zip.zipFile(Zip.java:474)
        at org.apache.tools.ant.taskdefs.Jar.zipFile(Jar.java:130)
        at org.apache.tools.ant.taskdefs.Zip.addFiles(Zip.java:260)
        at org.apache.tools.ant.taskdefs.Zip.addFiles(Zip.java:549)
        at org.apache.tools.ant.taskdefs.Zip.execute(Zip.java:186)
        at org.apache.tools.ant.Target.execute(Target.java:153)
        at org.apache.tools.ant.Project.runTarget(Project.java:898)
        at org.apache.tools.ant.Project.executeTarget(Project.java:536)
        at org.apache.tools.ant.Project.executeTargets(Project.java:510)
        at org.apache.tools.ant.Main.runBuild(Main.java:421)
        at org.apache.tools.ant.Main.main(Main.java:149)

Working target:

  <target name="system" depends="compile-system"
          description="Creates the system JAR file">
    <jar jarfile="${deploy.dir}/jars/captura/system_gen.jar"
         basedir="${build.dest}"
         compress="no">
             <include name="${system.pkg.dir}/common/**"/>
    </jar>

Non-working targets:

  <target name="system" depends="compile-system"
          description="Creates the system JAR file">
    <jar jarfile="${deploy.dir}/jars/captura/system_gen.jar"
         basedir="${build.dest}"
         compress="no">
         <fileset dir="${build.dest}"
             includes="${system.pkg.dir}/common/**"
         />
    </jar>

  <target name="system" depends="compile-system"
          description="Creates the system JAR file">
    <jar jarfile="${deploy.dir}/jars/captura/system_gen.jar"
         basedir="${build.dest}"
         compress="no">
         <fileset dir="${build.dest}">
             <include name="${system.pkg.dir}/common/**"/>
         </fileset>
    </jar>



Re: and problems...

Posted by Glenn McAllister <gl...@somanetworks.com>.
The jar task uses an implicit fileset.  The basedir attribute is equivalent to
the <fileset dir=...> element, and the include and exclude attribute are
(basically) equivalent to <fileset dir=...><include name="..."/></fileset>.

Jason Pringle wrote:

> Working target:
>
>   <target name="system" depends="compile-system"
>           description="Creates the system JAR file">
>     <jar jarfile="${deploy.dir}/jars/captura/system_gen.jar"
>          basedir="${build.dest}"
>          compress="no">
>              <include name="${system.pkg.dir}/common/**"/>
>     </jar>

This works because its including all the ${system.pkg.dir}/common/** files,
starting at ${build.dest}.

> Non-working targets:

<snip/>

>   <target name="system" depends="compile-system"
>           description="Creates the system JAR file">
>     <jar jarfile="${deploy.dir}/jars/captura/system_gen.jar"
>          basedir="${build.dest}"
>          compress="no">
>          <fileset dir="${build.dest}">
>              <include name="${system.pkg.dir}/common/**"/>
>          </fileset>
>     </jar>

This (and the one before it) doesn't work becuase you are declaring the same
set of files twice.  You are telling the jar task to take all the files in
basedir (${build.dest}) on down, and add them to the jar.  Then, with the
nested fileset, you are saying "Include all the ${system.pkg.dir}/common/**
files, starting from the ${build.dest} directory."  So you *are* in fact
including the ${system.pkg.dir}/common/** files twice.

If you want to use filesets, don't use the basedir attribute would be a good
rule of thumb.

Glenn