You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Ventimiglia, David" <Da...@msdw.com> on 2000/11/09 20:13:41 UTC

Problems with task

> Hi,
> 
> I'm getting many instances of this sort of error when trying to use the
> <jar> task:
> 
> Building jar: C:\deploy_root\foo.jar
> 
> BUILD FAILED
> 
> m:\dventimiglia_coreFoo_V1_integration\coreFoo\build.xml:165: Problem
> creating jar: duplicate entry: com/foo/online/aba/metro/AccountData.class
> java.util.zip.ZipException: duplicate entry:
> com/foo/online/aba/metro/AccountData.class
> 	at
> java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:165)
> 	at org.apache.tools.ant.taskdefs.Zip.zipFile(Zip.java:359)
> 	at org.apache.tools.ant.taskdefs.Zip.zipFile(Zip.java:374)
> 	at org.apache.tools.ant.taskdefs.Jar.zipFile(Jar.java:143)
> 	at org.apache.tools.ant.taskdefs.Zip.addFiles(Zip.java:212)
> 	at org.apache.tools.ant.taskdefs.Zip.execute(Zip.java:169)
> 	at org.apache.tools.ant.Target.execute(Target.java:142)
> 	at org.apache.tools.ant.Project.runTarget(Project.java:818)
> 	at org.apache.tools.ant.Project.executeTarget(Project.java:532)
> 	at org.apache.tools.ant.Project.executeTargets(Project.java:506)
> 	at org.apache.tools.ant.Main.runBuild(Main.java:420)
> 	at org.apache.tools.ant.Main.main(Main.java:149)
> 
> This happens when I try to use nested <fileset> elements with internally
> nested <include> and <exclude> elements, as in:
> 
>   <target name="jar" depends="init,classes">
>     <jar jarfile="${deploy.root}/foo.jar"
>          basedir="${build.dir}"
>          compress="${jar.compress}"
>          excludes="**/*Bean.class">
>       <fileset dir="${build.dir}">
>          <exclude name="**/*Bean.class"/>
>       </fileset>
>     </jar>
>   </target>
> 
> However, it works fine if I remove the nested <fileset> and collapse the
> "exclude" into the JAR task, as in:
> 
>   <target name="jar" depends="init,classes">
>     <jar jarfile="${deploy.root}/foo.jar"
>          basedir="${build.dir}"
>          compress="${jar.compress}"
>          excludes="**/*Bean.class"/>
>   </target>
> 
> Does anyone know why this might be happening?  Obviously, with only one
> "exclude" the collapsed version is simpler, but when I have many includes
> and excludes, I would like to use nested filesets.  I think this error is
> being emitted by jar.exe, but only because the <jar> task in Ant is not
> using it in a way that it likes to be used.  Since it appears <jar> does
> not log what files are discovered, the way <javac> helpfully does (even
> with -verbose or -debug options), it's hard for me to know how jar.exe is
> being used.
> 
> Thanks!
> 
> Cheers,
> David
> 
> 
> 

Re: Problems with task

Posted by Stefan Bodewig <bo...@bost.de>.
David Ventimiglia <Da...@msdw.com> wrote:

> I'm getting many instances of this sort of error when trying to use
> the <jar> task:
> 
> Building jar: C:\deploy_root\foo.jar
> 
> BUILD FAILED
> 
> m:\dventimiglia_coreFoo_V1_integration\coreFoo\build.xml:165:
> Problem creating jar: duplicate entry:
> com/foo/online/aba/metro/AccountData.class

> This happens when I try to use nested <fileset> elements with
> internally nested <include> and <exclude> elements, as in:
> 
>   <target name="jar" depends="init,classes">
>     <jar jarfile="${deploy.root}/foo.jar"
>          basedir="${build.dir}"
>          compress="${jar.compress}"
>          excludes="**/*Bean.class">
>       <fileset dir="${build.dir}">
>          <exclude name="**/*Bean.class"/>
>       </fileset>
>     </jar>
>   </target>

The problem here is, that you have two overlapping filesets. When you
specify a basedir, this creates an implicit fileset, i.e. what you
have above is identical to

     <jar jarfile="${deploy.root}/foo.jar"
          compress="${jar.compress}">
       <fileset dir="${build.dir}" excludes="**/*Bean.class" />
       <fileset dir="${build.dir}">
          <exclude name="**/*Bean.class"/>
       </fileset>
     </jar>

You are passing the same files twice to your <jar> task.

> However, it works fine if I remove the nested <fileset> and
> collapse the "exclude" into the JAR task, as in:

Sure, you could as well leave out the basedir and excludes attributes
in the jar tag. Now you are only having one fileset.

Hope this helps.

Stefan