我使用以下命令序列调用 maven
C:>\mvn install tomcat7:redeploy
这会产生以下(大量)编辑的输出
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ geomaster ---
[INFO] Copying 0 resource
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ geomaster ---
[INFO] No sources to compile
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ geomaster ---
[INFO] Copying 0 resource
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ geomaster ---
[INFO] No sources to compile
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ geomaster ---
[INFO] --- maven-war-plugin:2.2:war (default-war) @ geomaster ---
[INFO] --- maven-install-plugin:2.4:install (default-install) @ geomaster ---
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:redeploy (default-cli) @ geomaster >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ geomaster ---
[INFO] Copying 0 resource
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ geomaster ---
[INFO] No sources to compile
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ geomaster ---
[INFO] Copying 0 resource
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ geomaster ---
[INFO] No sources to compile
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ geomaster ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO] --- maven-war-plugin:2.2:war (default-war) @ geomaster ---
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:redeploy (default-cli) @ geomaster <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:redeploy (default-cli) @ geomaster ---
请忽略我的项目中没有资源或源代码的事实。这不是问题的关键。
install
目标用于将生成的war放入maven存储库中。 tomcat7:redeploy
目标用于将生成的 war 放入 tomcat 服务器中。
我尝试了各种调用和不同的配置,但我无法阻止 tomcat 插件执行它自己的构建,尽管 install
目标刚刚完成了它。
surefire 插件似乎有一些“智能”,因为它检测到它之前已经运行过。为什么 Maven 不能也有这种“智能”?
有关 tomcat 插件的其他信息可以在这里找到:tomcat7-maven-plugin
虽然由 tomcat 插件执行的第二个构建不会做任何实质性的事情,即使在一个更实质性的项目中,我怎样才能阻止它被执行,因为它完全是多余的?
这是 Maven 或 tomcat 插件中的错误吗?这可以作为请求增强的基础吗?或者这种预期的行为必须忍受?
最佳答案
从您链接到的 Tomcat 页面了解 deploy
goal ,它指出:
Invokes the execution of the lifecycle phase package prior to executing itself.
这就是它自己构建的原因。这是一个有意为之的功能,据我所知无法关闭。
但是deploy-only
目标存在:
Deploy a WAR to Tomcat without forking the package lifecycle
因此,如果您将命令更改为:
mvn install tomcat7:deploy-only
那么它应该做你想做的事。
关于maven - 阻止插件执行生命周期阶段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24282839/