默认生命周期、清理生命周期和站点生命周期
阶段执行时机
例如,执行mvn compile命令:
Maven将执行从验证阶段到编译阶段的所有阶段。
完整的阶段列表如下:(此处应补充完整的阶段列表)
目标在插件中定义,并绑定到特定的构建阶段。例如,maven-compiler-plugin插件中的compile目标绑定到compile阶段。
同一阶段中,不同插件的目标执行顺序由pom.xml文件中
查看绑定到package阶段的插件目标:
mvn help:describe -dcmd=package
以frontend-maven-plugin插件为例:
<plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>1.15.1</version> <executions> <execution> <id>install-node-and-npm</id> <goals> <goal>install-node-and-npm</goal> </goals> </execution> <execution> <id>npm install</id> <goals> <goal>npm</goal> </goals> </execution> ... </executions> </plugin>
install-node-and-npm和npm目标的定义类如下,它们绑定到generate-resources阶段:
@Mojo(name="install-node-and-npm", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true) public final class InstallNodeAndNpmMojo extends AbstractFrontendMojo { // ... } @Mojo(name="npm", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true) public final class NpmMojo extends AbstractFrontendMojo { // ... }
配置文件用于:
<profiles> <profile> <activation> <property> <name>debug</name> </property> </activation> ... </profile> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation> ... </profile> </profiles>
假设dev配置文件默认启用,要启用production配置文件并禁用dev配置文件:
mvn -P=-dev,production
以上就是Maven Notes(1)的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号