首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何禁用Maven 3中的默认生命周期阶段?

如何禁用Maven 3中的默认生命周期阶段?
EN

Stack Overflow用户
提问于 2013-03-06 14:02:41
回答 1查看 12.5K关注 0票数 14

我所说的禁用指的是完全、完全地从生命周期中删除这个阶段,这样它甚至不会被调用。

我可能需要一个自定义生命周期,但我无法找到在我的pom.xml中直接定义它的简单方法。似乎我需要写一个插件,只是为了列出我想要的阶段。

例如,我希望default-testResourcesdefault-testCompiledefault-test阶段永远不会发生,并从下面转出构建日志:

代码语言:javascript
复制
[INFO] ------------------------------------------------------------------------
[INFO] Building HelpDesk Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helpdesk ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory d:\proj\HelpDesk\repo\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ helpdesk ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helpdesk ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ helpdesk ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ helpdesk ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.3:war (default-war) @ helpdesk ---
[INFO] Packaging webapp
[INFO] Assembling webapp [helpdesk] in [d:\proj\HelpDesk\repo\target\helpdesk]
[INFO] Processing war project
[INFO] Copying webapp resources [d:\proj\HelpDesk\repo\src\main\webapp]
[INFO] Webapp assembled in [40 msecs]
[INFO] Building war: d:\proj\HelpDesk\repo\target\helpdesk.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

这方面:

代码语言:javascript
复制
[INFO] ------------------------------------------------------------------------
[INFO] Building HelpDesk Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helpdesk ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory d:\proj\HelpDesk\repo\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ helpdesk ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-war-plugin:2.3:war (default-war) @ helpdesk ---
[INFO] Packaging webapp
[INFO] Assembling webapp [helpdesk] in [d:\proj\HelpDesk\repo\target\helpdesk]
[INFO] Processing war project
[INFO] Copying webapp resources [d:\proj\HelpDesk\repo\src\main\webapp]
[INFO] Webapp assembled in [40 msecs]
[INFO] Building war: d:\proj\HelpDesk\repo\target\helpdesk.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-06 14:49:55

如果您想继续使用预定义的打包(jar、war等)你不能完全移除它们。您可以将打包作为pom,通过将您想要的目标绑定到所需的阶段来定义您自己的生命周期,或者您可以完全定义您自己的生命周期。您还可以将默认目标绑定到阶段none,以防止目标执行任何实际工作,如图所示。

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>default-testResources</id>
            <phase>none</phase>
        </execution>
    </executions>
</plugin>

所有这些一般来说,改变现有的预先构建的生命周期并不是最好的做法。

票数 17
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15249345

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档