Multi Module Project - Build Plugin

I am using Maven 2.0.9 to create a project with several modules. I defined the build plugin in my parent pom. I can assemble assemblies using

mvn install assembly:assembly 

This command runs the tests twice, once during the installation phase and another during the build. I tried assembly: single, but it throws an error. Any help to assemble my builds without running the tests twice is greatly appreciated.

+6
maven-2 maven-plugin
source share
3 answers

Calling the mojo assembly will force Maven to build the project using the normal life cycle, right down to the package phase. So, when you run:

 mvn install assembly:assembly 

you are actually telling maven to do a few things twice, and that includes the testing phase, as you can see in the default lifecycle documentation .

To avoid this, consider just running:

 mvn assembly:assembly 

Or bind the plugin to the project build life cycle:

 <project> ... <build> ... <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> ... </configuration> <executions> <execution> <id>make-assembly</id> <!-- this is used for inheritance merges --> <phase>package</phase> <!-- append to the packaging phase. --> <goals> <goal>single</goal> <!-- goals == mojos --> </goals> </execution> </executions> </plugin> ... </project> 
+7
source share

I think the error message is misleading, it suggests that you need to run the “package” phase in the same maven call as the plugin call itself.

Have you tried assembling "build mvn: build" or "build build mvn: build"?

Works for me under Linux, JDK 1.6.0_16, Maven 2.2.1, Assembly Plugin 2.2-beta-4.

+1
source share

You need to create a separate project for assembly in a multi-module project. This separate module will only compile - and it will have dependencies: siblings to be added to the results assembly.

Read this article: http://www.sonatype.com/books/mvnref-book/reference/assemblies-sect-best-practices.html

+1
source share

All Articles