1
votes

I'm creating some runnable JARs (desktop JavaFX applications).

I have a fileset of the 3rd party JARs I'm including:

<fileset id="shared_lib" dir="${aux.debian.lib.dir}">
    <include name="commons-lang3-3.4.jar"/>
    <include name="commons-io-2.4.jar"/>
    ...
</fileset>

And I then use zipgroupfileset to include those in the final runnable JAR:

<jar destfile="myapp.jar" filesetmanifest="mergewithoutmain">
    <zipgroupfileset refid="shared_lib"/>
    <manifest>
        <attribute name="Main-Class" value="mypackage.myapp"/>
        <attribute name="Class-Path" value="."/>
    </manifest>
    <fileset dir="./classes" />
</jar>

When I then run ProGuard I get the following warnings multiple times (as each of the zipped JARs contain a LICENSE.txt and NOTICE.txt):

[proguard] Warning: can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [myapp.jar:META-INF/LICENSE.txt])
[proguard] Warning: can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [myapp.jar:META-INF/NOTICE.txt])

I've tried the various exclude options when defining the fileset, but they only exclude files from the fileset, not from within the include JARs.

Is there away to simply filter what gets zipped as part of the zipgroupfileset? Perhaps in ProGuard?

This is only a minor annoyance, as everything works with the warnings, but it's annoying me that something that I have a feeling should be simple is eluding me.

1
Have you tried adding duplicate="preserve" to your <jar> element, as described in the documentation?VGR
@VGR thanks. That worked, and was as simple as I suspected it would be, I was just looking for options in ProGuard and the fileset. Do you want to post it as an answer?Andy Nugent

1 Answers

2
votes

You can add duplicate="preserve" to your <jar> element, as described in the documentation:

duplicate

  • behavior when a duplicate file is found. Valid values are "add", "preserve", and "fail". The default value is "add".