David Ventimiglia <David.Ventimiglia@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
|