You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Daniel Gredler (JIRA)" <ji...@codehaus.org> on 2008/07/17 21:51:29 UTC

[jira] Created: (MASSEMBLY-341) Fat JAR assemblies may result in JARs with duplicate files

Fat JAR assemblies may result in JARs with duplicate files
----------------------------------------------------------

                 Key: MASSEMBLY-341
                 URL: http://jira.codehaus.org/browse/MASSEMBLY-341
             Project: Maven 2.x Assembly Plugin
          Issue Type: Bug
         Environment: Maven 2.0.8
            Reporter: Daniel Gredler


When building a fat JAR assembly (format=jar, dependencySet.unpack=true), if some of the dependencies contain files with the same path and name as files in any other dependencies and/or the current project, the generated JAR file contains duplicate files.

The root issue is that ZIP files allow duplicate files, and JAR files are just special ZIP files. However, when a JAR file contains duplicate files, the results are unpredictable -- there's no way to know which file "wins."

Internally, (as far as I can tell) Maven's DefaultAssemblyArchiver [2] uses an ArchiverManager to get an Archiver based on the format name ("jar"). This Archiver is probably a MavenArchiver [3], which delegates to a JarArchiver [4], which is a subclass of ZipArchiver [5] and AbstractZipArchiver [6]. AbstractZipArchiver has a protected instance variable of type String named "duplicate", the values of which can be one of "preserve", "fail" and "add". The default is "add".

I'm not sure if this needs to be fixed at the JarArchiver level (initialize the "duplicate" instance var to "preserve"), or at the DefaultAssemblyArchiver level (as was done with WAR assemblies for MNG-1274 -- see the createWarArchiver() method), or somewhere else.

As an example of how other projects handle this, Ant's Jar task documentation page [1] includes a bolded warning which describes the issue and provides the "duplicate" attribute, which can be set to "add", "preserve" or "fail".


[1] http://ant.apache.org/manual/CoreTasks/jar.html
[2] http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiver.java
[3] http://maven.apache.org/shared/maven-archiver/xref/index.html
[4] http://fisheye.codehaus.org/browse/~raw,r=4612/plexus/plexus-components/trunk/plexus-archiver/src/main/java/org/codehaus/plexus/archiver/jar/JarArchiver.java
[5] http://fisheye.codehaus.org/browse/~raw,r=4573/plexus/plexus-components/trunk/plexus-archiver/src/main/java/org/codehaus/plexus/archiver/zip/ZipArchiver.java
[6] http://fisheye.codehaus.org/browse/~raw,r=4573/plexus/plexus-components/trunk/plexus-archiver/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Closed: (MASSEMBLY-341) Fat JAR assemblies may result in JARs with duplicate files

Posted by "John Casey (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MASSEMBLY-341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Casey closed MASSEMBLY-341.
--------------------------------

       Resolution: Duplicate
    Fix Version/s: 2.2-beta-3

See MASSEMBLY-285. The latest code supports the following plugin configuration:

{code:xml}
<archiverConfig>
  <duplicateBehavior>skip</duplicateBehavior>
</archiverConfig>
{code}

The default setting is 'add' which allows duplicates.

> Fat JAR assemblies may result in JARs with duplicate files
> ----------------------------------------------------------
>
>                 Key: MASSEMBLY-341
>                 URL: http://jira.codehaus.org/browse/MASSEMBLY-341
>             Project: Maven 2.x Assembly Plugin
>          Issue Type: Bug
>         Environment: Maven 2.0.8
>            Reporter: Daniel Gredler
>            Assignee: John Casey
>             Fix For: 2.2-beta-3
>
>
> When building a fat JAR assembly (format=jar, dependencySet.unpack=true), if some of the dependencies contain files with the same path and name as files in any other dependencies and/or the current project, the generated JAR file contains duplicate files.
> The root issue is that ZIP files allow duplicate files, and JAR files are just special ZIP files. However, when a JAR file contains duplicate files, the results are unpredictable -- there's no way to know which file "wins."
> Internally, (as far as I can tell) Maven's DefaultAssemblyArchiver [2] uses an ArchiverManager to get an Archiver based on the format name ("jar"). This Archiver is probably a MavenArchiver [3], which delegates to a JarArchiver [4], which is a subclass of ZipArchiver [5] and AbstractZipArchiver [6]. AbstractZipArchiver has a protected instance variable of type String named "duplicate", the values of which can be one of "preserve", "fail" and "add". The default is "add".
> I'm not sure if this needs to be fixed at the JarArchiver level (initialize the "duplicate" instance var to "preserve"), or at the DefaultAssemblyArchiver level (as was done with WAR assemblies for MNG-1274 -- see the createWarArchiver() method), or somewhere else.
> As an example of how other projects handle this, Ant's Jar task documentation page [1] includes a bolded warning which describes the issue and provides the "duplicate" attribute, which can be set to "add", "preserve" or "fail".
> [1] http://ant.apache.org/manual/CoreTasks/jar.html
> [2] http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiver.java
> [3] http://maven.apache.org/shared/maven-archiver/xref/index.html
> [4] http://fisheye.codehaus.org/browse/~raw,r=4612/plexus/plexus-components/trunk/plexus-archiver/src/main/java/org/codehaus/plexus/archiver/jar/JarArchiver.java
> [5] http://fisheye.codehaus.org/browse/~raw,r=4573/plexus/plexus-components/trunk/plexus-archiver/src/main/java/org/codehaus/plexus/archiver/zip/ZipArchiver.java
> [6] http://fisheye.codehaus.org/browse/~raw,r=4573/plexus/plexus-components/trunk/plexus-archiver/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira