How to suppress ant jar warnings for duplicates

I don't need an ant jar task to notify me every time it skips a file, because the file has already been added. I receive the following messages:

 [jar] xml/dir1/dir2.dtd already added, skipping

      

Is there a way to disable this warning?

+2


source to share


2 answers


This is an old question, but there is one obvious way to eliminate the duplicate warning, not include duplicate files. You can do this in one of two ways:

  • Eliminate duplicate files in some way, or
  • Copy the files to the staging area so the cp task deals with duplicates and not the jar task.

So instead of doing:

<jar destfile="${dist}/lib/app.jar">
  <fileset dir="a" include="xml/data/*.{xml,dtd}"/>
  <fileset dir="b" include="xml/data/*.{xml,dtd}"/>
  <fileset dir="c" include="xml/data/*.{xml,dtd}"/>
</jar>

      

Perform one of the following actions:



<jar destfile="${dist}/lib/app.jar">
  <fileset dir="a" include="xml/data/*.{xml,dtd}"/>
  <fileset dir="b" include="xml/data/*.xml"/>
  <fileset dir="c" include="xml/data/*.xml"/>
</jar>

      

or

<copy todir="tmpdir">
  <fileset dir="a" include="xml/data/*.{xml,dtd}"/>
  <fileset dir="b" include="xml/data/*.{xml,dtd}"/>
  <fileset dir="c" include="xml/data/*.{xml,dtd}"/>
</copy>
<jar destfile="${dist}/lib/app.jar">
  <fileset dir="tmpdir" include="xml/data/*.{xml,dtd}"/>
</jar>
<delete dir="tmpdir"/>

      

Edit . Based on the comment on this answer, there is a third option, although this is pretty honest work. You can always get the source in the task jar and change so that it doesn't print out warnings. You can save this as a local modification of your tree, move it to another package and save it yourself, or try to revert the patch back.

+2


source


I don't know of any parameters in the jar task to suppress these messages, unless you run the entire build with - quiet , in which case you may not see the other information you want.

In general, if you have a lot of duplicate files, this is a good thing to warn them about, since you can add another to what you expect. This may indicate that the previous build target did not do its job as well as it could, although obviously it is impossible to tell without any details.



Out of interest, why do you have duplicate files?

+1


source







All Articles