Apache Maven Assembly Plugin 文档
assembly:assembly
Full name:
org.apache.maven.plugins:maven-assembly-plugin:2.6:assembly
This plugin goal has been deprecated:
Description:
NOTE: This goal should ONLY be run from the command line, and if building a multimodule project it should be used from the root POM. Use the assembly:single goal for binding your assembly to the lifecycle.
Attributes:
- Requires a Maven project to be executed.
- Executes as an aggregator plugin.
- Invokes the execution of the lifecycle phase package prior to executing itself.
- Is NOT inherited by default in multi-project builds.
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. I list these two goals in different ways because it reflects 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 which 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 can result in builds which end up executing the package phase twice.
Because the assembly:assembly goal is an aggregator mojo, it raises some issues in multi-module Maven builds, and it should only be called as a stand-alone 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 assembly archives were a legitimate requirement for projects to produce, thesingle mojo was developed. This mojo assumes that it has been bound to the correct part of the build process, so that it will have access to the project files and artifacts it needs to execute within the lifecycle of a large multi-module Maven project. In a multi-module environment, it will execute as many times as it is bound to the different module POMs. Unlikeassembly:assembly, single will never force the execution of another lifecycle phase ahead of itself.
The Assembly plugin provides several other goals in addition to these two. However, discussion of these other mojos is beyond the scope of this chapter, because they serve exotic or obsolete use cases, and because they are almost never needed. Whenever possible, you should definitely stick to using assembly:assembly for assemblies generated from the command line, and to single for assemblies bound to lifecycle phases.
本文详细介绍了 Apache Maven Assembly Plugin 的两个主要目标:assembly:assembly 和 single mojo。assembly:assembly 适用于从命令行直接调用,而 single 则用于日常构建流程中,并绑定到项目构建生命周期阶段。

被折叠的 条评论
为什么被折叠?



