Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi Module Project - Assembly plugin

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.

like image 516
user209947 Avatar asked Nov 14 '09 21:11

user209947


People also ask

What is Maven Assembly plugin?

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.

What is Maven Multi-Module?

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.

What is multi-module application?

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.


1 Answers

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>
like image 143
Pascal Thivent Avatar answered Nov 02 '22 11:11

Pascal Thivent