Reputation: 1175
I have something like the following where I need to generate 2 zip files and finally zip them up to another zip file:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly1</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>assembly1</finalName>
<descriptors>
<descriptor>assembly1.xml</descriptor>
</descriptors>
<attach>true</attach>
</configuration>
</execution>
<execution>
<id>assembly2</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>assembly2</finalName>
<descriptors>
<descriptor>assembly2.xml</descriptor>
</descriptors>
<attach>true</attach>
</configuration>
</execution>
<execution>
<id>assembly3</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>assembly3</finalName>
<descriptors>
<descriptor>assembly3.xml</descriptor>
</descriptors>
<attach>true</attach>
</configuration>
</execution>
</executions>
</plugin>
What I am trying to do is creating 2 zip files called assembly1.zip and assembly2.zip, finally zip these 2 zip files into assembly3.zip
Under the target folder, I see the zip files created and in assembly3.zip, I see the assembly1 and 2 zip files as well.
When Maven uploads to the local repo, it randomly picks up one of the zip files and what I want to be uploaded is the assembly3.zip file.
This is what I see in the Maven log:
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (assembly1) @ MyTestWar ---
[INFO] Reading assembly descriptor: assembly1.xml
[INFO] Building zip: C:\MyTest\target\assembly1.zip
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (assembly2) @ MyTestWar ---
[INFO] Reading assembly descriptor: assembly2.xml
[INFO] Building zip: C:\MyTest\target\assembly2.zip
**[WARNING] Artifact com.test:MyTestWar:zip:1.0.0.11-SNAPSHOT already attached to project, ignoring duplicate**
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (assembly3) @ MyTestWar ---
[INFO] Reading assembly descriptor: assembly3.xml
[INFO] Building zip: C:\MyTest\target\assembly3.zip
**[WARNING] Artifact com.test:MyTestWar:zip:1.0.0.11-SNAPSHOT already attached to project, ignoring duplicate**
**[INFO] Installing C:\MyTest\target\assembly1.zip to C:\Users\myUserName\.m2\repository\
com\test\MyTestWar\1.0.0.11-SNAPSHOT\MyTestWar-1.0.0.11-SNAPSHOT.zip**
This is my Maven install plugin where I try to upload Assembly3.zip
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<id>zip-upload</id>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>zip</packaging>
<artifactId>Assembly3</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>${project.build.directory}/assembly3.zip</file>
</configuration>
</execution>
</executions>
</plugin>
Though it is mentioned that it got to upload assembly3.zip, for some reason Maven is picking up assembly1.zip.
Also I am interested in those Warnings.
Any help in getting rid of the warnings as well as uploading Assembly3.zip is highly appreciated.
Thanks
Upvotes: 3
Views: 3957
Reputation: 23248
Use
<attach>true</attach>
only for the assembly you want to upload. For the other two executions, omit this option.
As for why it is picking a random assembly instead of uploading all three, I'm guessing the assembly ID in your assembly descriptors are all the same. The error message
[WARNING] Artifact com.test:MyTestWar:zip:1.0.0.11-SNAPSHOT already attached to project, ignoring duplicate
hints at this. Even if you have given the zips different finalName values, they still inherit the classifier from the ID in the assembly descriptor.
Upvotes: 2