I am using Maven 2.0.9 to build a multi module project. I have defined the assembly plugin in my parent pom. I can get my assemblies built using
mvn install assembly:assembly
This command runs the tests twice, once during install phase and another during assembly. I tried assembly:single but it throws an error. Any help to get my assemblies built without running the tests twice is much appreciated.
The Assembly Plugin for Maven enables developers to combine project output into a single distributable archive that also contains dependencies, modules, site documentation, and other files. Your project can easily build distribution "assemblies" using one of the prefabricated assembly descriptors.
A multi-module project is built from an aggregator POM that manages a group of submodules. In most cases, the aggregator is located in the project's root directory and must have packaging of type pom. The submodules are regular Maven projects, and they can be built separately or through the aggregator POM.
A Spring Boot project that contains nested maven projects is called the multi-module project. In the multi-module project, the parent project works as a container for base maven configurations. In other words, a multi-module project is built from a parent pom that manages a group of submodules.
Invoking the assembly mojo will cause Maven to build the project using the normal lifecycle, up to the package
phase. So, when you run:
mvn install assembly:assembly
you are actually telling maven to run a few things twice and this includes the test phase as you can see in the documentation of the default lifecycle.
To avoid this, consider running only:
mvn assembly:assembly
Or bind the plugin on a project's build lifecycle:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With