Maven生命周期与Ant插件

Maven 对构建生命周期的固定理解包含了许多不同的阶段,如下表:
[table]
|validate|验证|确保当前配置和POM的内容是有效的。这包含对pom文件树的验证。
|initialize|初始化|在执行构建生命周期的主任务之前可以进行初始化。
|generate-sources|生成源码|代码生成器可以开始生成在以后阶段中处理或编译的源代码。
|process-sources|处理源码|提供解析、修改和转换源码。常规源码和生成的源码都可以在这里处理。
|generate-resources|生成资源|可以生成非源码资源。通常包括元数据文件和配置文件。
|process-resources|处理资源|处理非源码资源。修改、转换和重定位资源都能在这阶段发生。
|compile|编译|编译源码。编译过的类被放到目标目录树中。
|process-classes|处理类|处理类文件转换和增强步骤。字节码交织器和常用工具常在这一阶段操作。
|generate-test-sources|生成测试源码|mojo可以生成要操作的单元测试代码。
|process-test-sources|处理测试源码|在编译前对测试源码执行任何必要的处理。在这一阶段,可以修改、转换或复制源代码。
|generate-test-resources|生成测试资源|允许生成与测试相关的(非源码)资源。
|process-test-resources|处理测试资源|可以处理、转换和重新定位与测试相关的资源。
|test-compile|测试编译|编译单元测试的源码。
|test|测试|运行编译过的单元测试并累计结果。
|package|打包|将可执行的二进制文件打包到一个分布式归档文件中,如
|pre-integration-test|前集成测试、准备集成测试|这种情况下的集成测试是指在一个受到一定控制的模拟的真实部署环境中测试代码。这一步能将归档文件部署到一个服务器上执行。
|integration-test|集成测试|执行真正的集成测试。
|post-integration-test|后集成测试、解除集成测试准备|这一步涉及测试环境重置或重新初始化。
|verify|检验|检验可部署归档的有效性和完整性。过了这个阶段,将安装该归档。
|install|安装|将该归档添加到本地Maven目录。这一步让其他可能依赖该归档的模块可以使用它。
|deploy|部署|将该归档添加到远程Maven目录。这一步让这个工件能为更多的人所用。
[/table]

ANT 插件:

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<configuration>
<tasks>
<tstamp>
<format property="build-time" pattern="d-MMMM-yyyy HH:mm"/>
</tstamp>
<copy file="src/main/java/com/.../Version.java.template" toFile="src/main/java/com/.../Version.java" overwrite="true">
<filterset>
<filter token="version-major" value="${version-major}"/>
<filter token="version-minor" value="${version-minor}"/>
<filter token="version-revision" value="${version-revision}"/>
<filter token="version-status" value="${version-status}"/>
<filter token="version" value="${project.version}"/>
<filter token="Name" value="${project.name}"/>
<filter token="website" value="${project.url}"/>
<filter token="build-time" value="${build-time}"/>
</filterset>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>


Maven命令选项:

usage: maven [options] [<goal(s)>] [<phase(s)>]

Options:
-C,--strict-checksums Fail the build if checksums don't match
-c,--lax-checksums Warn if checksums don't match
-P,--activate-profiles Comma-delimited list of profiles to
activate
-ff,--fail-fast Stop at first failure in reactorized builds
-fae,--fail-at-end Only fail the build afterwards; allow all
non-impacted builds to continue
-B,--batch-mode Run in non-interactive (batch) mode
-fn,--fail-never NEVER fail the build, regardless of project
result
-up,--update-plugins Synonym for cpu
-N,--non-recursive Do not recurse into sub-projects
-npr,--no-plugin-registry Don't use ~/.m2/plugin-registry.xml for
plugin versions
-U,--update-snapshots Update all snapshots regardless of
repository policies
-cpu,--check-plugin-updates Force upToDate check for any relevant
registered plugins
-npu,--no-plugin-updates Suppress upToDate check for any relevant
registered plugins
-D,--define Define a system property
-X,--debug Produce execution debug output
-e,--errors Produce execution error messages
-f,--file Force the use of an alternate POM file.
-h,--help Display help information
-o,--offline Work offline
-r,--reactor Execute goals for project found in the
reactor
-s,--settings Alternate path for the user settings file
-v,--version Display version information
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值