如何通过 windows 中的构建脚本文件执行 Maven 生命周期阶段
How to exceute the maven lifecycle phases through the build script file in windows
我是 Maven 的新手。我目前正在从事 Maven 多模块项目。我想从 Windows 中的脚本文件执行 Maven 生命周期阶段。我的意思是当我们 运行 这个脚本文件然后 validate
, test
, compile
, package
, install
, deploy
这些阶段应该 运行 自动。
我还完成了 pom.xml
中的 Maven 目标以及执行程序和汇编程序插件。
但是我无法得到我的解决方案。那么我应该如何在 windows.
中为此创建构建脚本文件呢?
参见Maven, Introduction to the Build Lifecycle:
These lifecycle phases (plus the other lifecycle phases not shown here) are executed sequentially to complete the default
lifecycle. Given the lifecycle phases above, this means that when the default lifecycle is used, Maven will first validate the project, then will try to compile the sources, run those against the tests, package the binaries (e.g. jar), run integration tests against that package, verify the package, install the verifed package to the local repository, then deploy the installed package in a specified environment.
To do all those, you only need to call the last build phase to be executed, in this case, deploy
:
mvn deploy
That is because if you call a build phase, it will execute not only that build phase, but also every build phase prior to the called build phase.
长话短说:如果您在脚本中调用 mvn deploy
,则您提到的所有阶段(甚至更多)都已经按照设计由 Maven 传递。
关于“pom.xml
中的 Maven 目标”——Maven 和 POM 本身没有目标。您可以将目标(由 plugins 提供)绑定到后者的生命周期阶段。请参阅 Maven: Lifecycle vs. Phase vs. Plugin vs. Goal 了解这些 Maven 术语的全部内容。
延伸阅读:
我是 Maven 的新手。我目前正在从事 Maven 多模块项目。我想从 Windows 中的脚本文件执行 Maven 生命周期阶段。我的意思是当我们 运行 这个脚本文件然后 validate
, test
, compile
, package
, install
, deploy
这些阶段应该 运行 自动。
我还完成了 pom.xml
中的 Maven 目标以及执行程序和汇编程序插件。
但是我无法得到我的解决方案。那么我应该如何在 windows.
中为此创建构建脚本文件呢?参见Maven, Introduction to the Build Lifecycle:
These lifecycle phases (plus the other lifecycle phases not shown here) are executed sequentially to complete the
default
lifecycle. Given the lifecycle phases above, this means that when the default lifecycle is used, Maven will first validate the project, then will try to compile the sources, run those against the tests, package the binaries (e.g. jar), run integration tests against that package, verify the package, install the verifed package to the local repository, then deploy the installed package in a specified environment.To do all those, you only need to call the last build phase to be executed, in this case,
deploy
:mvn deploy
That is because if you call a build phase, it will execute not only that build phase, but also every build phase prior to the called build phase.
长话短说:如果您在脚本中调用 mvn deploy
,则您提到的所有阶段(甚至更多)都已经按照设计由 Maven 传递。
关于“pom.xml
中的 Maven 目标”——Maven 和 POM 本身没有目标。您可以将目标(由 plugins 提供)绑定到后者的生命周期阶段。请参阅 Maven: Lifecycle vs. Phase vs. Plugin vs. Goal 了解这些 Maven 术语的全部内容。
延伸阅读: