You are previewing Maven: The Definitive Guide.

Maven: The Definitive Guide

Cover of Maven: The Definitive Guide by Sonatype Company Published by O'Reilly Media, Inc.
O'Reilly logo

Assembly Basics

Before we go any further, it’s best to take a minute and talk about the two main goals in the Assembly plugin: assembly:assembly and the single mojo. We list these two goals in different ways to reflect the difference in how they’re used. The assembly:assembly goal is designed to be invoked directly from the command line and should never be bound to a build lifecycle phase. In contrast, the single mojo is designed to be a part of your everyday build and should be bound to a phase in your project’s build lifecycle.

The main reason for this difference is that the assembly:assembly goal is what Maven terms an aggregator mojo—that is, a mojo that is designed to run at most once in a build, regardless of how many projects are being built. It draws its configuration from the root project, usually the top-level POM or the command line. When bound to a lifecycle, an aggregator mojo can have some nasty side effects. It can force the execution of the package lifecycle phase to execute ahead of time, and it can result in builds that end up executing the package phase twice.

Because the assembly:assembly goal is an aggregator mojo, it raises some issues in multimodule Maven builds, and it should be called only as a standalone mojo from the command line. Never bind an assembly:assembly execution to a lifecycle phase. assembly:assembly was the original goal in the Assembly plugin and was never designed to be part of the standard build process for a project. As it became clear that ...

The best content for your career. Discover unlimited learning on demand for around $1/day.