简体   繁体   English

在 Maven 多模块项目中,如何在一个孩子上运行完整构建并运行特定插件?

[英]In a Maven multi-module project, how can I run a full build and run a specific plugin on one child?

I have a multi-project maven project.我有一个多项目 Maven 项目。 One child only has a specific plugin and I want it to be optional (so not bound to a specific phase).一个孩子只有一个特定的插件,我希望它是可选的(因此不受特定阶段的约束)。 How can I run a full clean install on the entire project and additionally run a project's specific plugin?如何在整个项目上运行完整的全新安装并另外运行项目的特定插件?

I've encountered this post but it looks like an overkill, and it is not so easy in my specific case.我遇到过这篇文章,但它看起来有点矫枉过正,在我的具体情况下并不容易。

Your best option is to use maven build profiles .您最好的选择是使用Maven 构建配置文件

In example, use this snippet in child module:例如,在子模块中使用此代码段:

<profiles>
    <profile>
        <id>only-in-child-module</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <plugins>
                ....
            </plugins>
        </build>
    </profile>
</profiles>

This build profile will not be active unless you explicitly ask maven for it like:除非您明确要求 Maven,否则此构建配置文件不会处于活动状态,例如:

mvn clean install -Ponly-in-child-module

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM