Issue Details (XML | Word | Printable)

Key: MASSEMBLY-285
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: John Casey
Reporter: Brett Porter
Votes: 20
Watchers: 25
Operations

If you were logged in you would be able to see more operations.
Maven 2.x Assembly Plugin

regression: duplicate files added to the assembly

Created: 22/Feb/08 01:06 AM   Updated: Thursday 01:44 PM
Component/s: None
Affects Version/s: 2.2-beta-1
Fix Version/s: 2.2-beta-3

Time Tracking:
Issue & Sub-Tasks
Issue Only
Not Specified

Issue Links:
Duplicate
 
Related
dependent

Sub-Tasks  All   Open   

 Description  « Hide
I found that it was possible to add a file twice to the assembly through different filesets (a zip file) so that when it extracted it prompted for overwrite.

It should error out or collapse the entries (as 2.1 did).



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Andrew Perepelytsya added a comment - 30/Mar/08 06:05 PM
2.2-beta-2 is badly broken due to this. Does it really take so much time to fix the regression? Pleease?

Andrew Perepelytsya added a comment - 30/Mar/08 06:10 PM
This is reproduced when one tries e.g. to configure permissions on the files in the directory using multiple include/exclude patterns. Each FileSet is instead copied and duplicated in zip. E.g. real config that broke: http://svn.galaxy.muleforge.org/browse/galaxy/trunk/netboot/mule1/distribution/assembly.xml?r=487

Alan Cabrera added a comment - 01/Apr/08 04:03 PM
This jacks up my world as my jar signer freaks out when it sees the duplicate files.

Michael Mattox added a comment - 24/Apr/08 02:17 PM - edited
I'm having this problem too when making a WAR file.

Any news on a possible fix?? It's been 3 weeks now without an update.


Amir Eliaz added a comment - 21/May/08 01:52 AM
This is happening also with tar.gz format.
The resulting tar file contains many copies of several Jar artifacts, multiplying its size by ~4.
When extracting, only one copy is left per artifact.

Andrei Solntsev added a comment - 03/Jun/08 08:41 AM
I have a project with several submodules, each of them creates a ZIP during build.

When I build submodules one by one, they produce correct ZIPs.
But when i build the entire project with all submodules, their ZIPs contain duplicated entries.


Artur Zielazny added a comment - 07/Aug/08 07:40 AM
Similar situation while assembling multimodule project to ZIP using
<moduleSets>
<moduleSet>
<includes>
...
in assembly.xml

gotama added a comment - 13/Aug/08 03:25 PM

I found this bug while trying to merge 2 <fileset> directories expecting that the 2nd would overwrite the first set of files where they overlap (in using one fileset as "default" files and the 2nd fileset as overrides).

The result was as described in the bug - 2 identical files added to the resulting zip file. Upon extraction of the zip, I was prompted for an option to override one of the files. I also verified that the case on both files was lower case, so its NOT an issue with the same filename with different case; ie creating the archive on unix and extracting on Windows.

This bug has been open for a long time. It would be appreciated if this was fixed ASAP. Its a huge blocker. Thanks!

example assembly.xml file:

<assembly xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.1.0-SNAPSHOT.xsd">

<id>bin</id>

<formats>
<format>zip</format>
</formats>

<fileSets>
<fileSet>
<!--must use absolute reference with ${pom.basedir} to achieve filtering -->
<directory>${pom.basedir}/src/main/config/defaults/</directory>
<outputDirectory>${pom.basedir}/target/work/</outputDirectory>
<filtered>true</filtered>
</fileSet>
<fileSet>
<!-- must use absolute reference with ${pom.basedir} to achieve filtering -->
<directory>${pom.basedir}/src/main/config/overrides/</directory>
<outputDirectory>${pom.basedir}/target/work/</outputDirectory>
<filtered>true</filtered>
</fileSet>
</fileSets>

</assembly>


gotama added a comment - 13/Aug/08 03:31 PM

Until this is fixed, here is an example work around, if you are interested (the modules parent is a default jboss-assembly module - the child module inherits the src and config of the default jboss-assembly):

pom.xml:

<plugins>

<!-- generate resources. merge default and current configurations. -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<configuration>
<tasks>
<copy todir="${project.build.directory}/generated-resources/"
preservelastmodified="true" verbose="true" overwrite="true">
<fileset dir="${basedir}/../jboss-assembly/src/main/config/"/>
</copy>
<copy todir="${project.build.directory}/generated-resources/"
preservelastmodified="true" verbose="true" overwrite="true">
<fileset dir="${basedir}/src/main/config/"/>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

<-- maven assembly plugin -->
</plugins>


John Casey added a comment - 18/Sep/08 05:23 PM
You'll need to specify the following in your plugin's configuration section:
<archiverConfig>
  <duplicateBehavior>skip</duplicateBehavior>
</archiverConfig>

John Casey added a comment - 18/Sep/08 05:24 PM
the default duplicates setting for the zip archiver is "add", meaning allow duplicates. This logic has been preserved, and using the archiverConfig element of the plugin configuration you an override it. BTW, the duplicates-handling logic from the zip archiver has been generalized out to the AbstractArchiver, so all archivers should handle it.

Artur Zielazny added a comment - 19/Sep/08 07:28 AM
With following configuration placed in parent's POM:

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-3-SNAPSHOT</version>
<configuration>
<archiverConfig>
<duplicateBehaviour>skip</duplicateBehaviour>
</archiverConfig>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
<outputDirectory>target</outputDirectory>
</configuration>
</plugin>

used in multimodule project (parent, then few modules as child), this is still adding duplicates into the final ZIP archive. <duplicateBehaviour>fail</duplicateBehaviour> does not fail as well.

I will appreciate any help.


Artur Zielazny added a comment - 19/Sep/08 07:31 AM
With duplicateBehavior instead of duplicateBehaviour (one letter changed) it still does not work.

Antony Stubbs added a comment - 06/Oct/08 06:21 AM
Shouldn't the default behaviour be the 'correct' behaviour? What percentage of people actually want duplicate files in their artefacts?

Why should we try to preserve incorrect behaviour? This sort of thing cripples products - just look at the www.

Please point it out if there's something I'm missing.


Dan Diephouse added a comment - 06/Oct/08 07:21 AM
I heartily agree with Antony here - please reopen this issue!

Alan Cabrera added a comment - 06/Oct/08 09:42 AM
I agree as well.

Julien S added a comment - 06/Oct/08 10:17 AM
I just to give one more voice on the topic, I also strongly agree that the "normal" behavior is not to duplicate files.

Benjamin Bentmann added a comment - 06/Oct/08 10:41 AM

Shouldn't the default behaviour be the 'correct' behaviour?

+1, following Maven's spirit of "convention over configuration" where the convention of course should be sensible, i.e. cover the major use case.


Erik Engstrom added a comment - 06/Oct/08 11:17 AM
I agree that the default behaviour should be to not allow duplicates. I also think that the default should be to overwrite, not to skip. So that it works just like copying files to a directory.

Alison Winters added a comment - 06/Oct/08 05:15 PM
I strongly agree. Every time we have to put workarounds in our poms we're just taking another step back to ant build.xmls. I honestly can't think of any case where it would be useful to have two of the same file in an archive. My vote would be to overwrite and warn.

Daniel Gredler added a comment - 17/Oct/08 03:50 PM
+1 on defaulting to overwrite, at least if the assembly is building a jar or a war...

Antony Stubbs added a comment - 20/Oct/08 07:10 AM
Hi everyone, glad to see you all agree!

Have opened a new issue to cover this, as this one has been officially closed and doesn't seem to be getting much attention:
http://jira.codehaus.org/browse/MASSEMBLY-361

Please go and vote for it!


John Casey added a comment - 05/Dec/08 11:54 AM
investigating

John Casey added a comment - 10/Dec/08 01:35 PM
default behavior is set to skip. Because of the way archive resources are processed, implementing overwrite is going to be a lot more involved. From the perspective of the assembly plugin, overwrite vs. skip doesn't make much difference, since users cannot control which type of assembly section is processed first, and any of them could overwrite entries from any other. Having duplicate files that are different will lead to non-deterministic results as long as you're not talking about any two specific sections, or entries within a single section, so there is no difference in the general case between skip and overwrite.

In terms of two fileSets, however, it makes sense to allow overwrites. Since this is pretty complex to implement in plexus-archiver, I'll create a new issue for it and assign it to 2.2 (final).


John Casey added a comment - 10/Dec/08 01:36 PM
verified as fixed in src/it/projects/bugs/massembly-285

Daniel Gredler added a comment - 10/Dec/08 02:10 PM
Let me make sure I'm clear on this. If my assembly.xml file has a "dependencySets" node (containing a single "dependencySet") followed by a "fileSets" node (containing a single "fileSet"), neither the order of the nodes nor the intrinsic meaning of the nodes affects the order in which they are processed? The processing order is non-deterministic?