【问题标题】:How to skip maven child module build如何跳过 Maven 子模块构建
【发布时间】:2012-05-30 19:33:00
【问题描述】:

我有类似的项目

module1
module2
module3
 submodule1
    src
      main
        java
        resources
    child1
    child2
module4

当我在项目上运行 mvn clean install 时,所有顶部和子模块都会构建。但是我希望maven不要执行child1,child2。我怎么能做到这一点。我发现使用配置文件我可以做到这一点。但是怎么做?我可以在 submodule1 pom 中做一些事情,以便 child1、child2 从 maven 阶段中排除吗?

【问题讨论】:

    标签: maven-2 exec-maven-plugin


    【解决方案1】:

    是的,这很容易。在submodule1的pom中,默认只包含src:

    <modules>
        <module>src</module>
    </modules>
    

    然后在默认情况下禁用的特殊配置文件中,您构建所有这些文件

    <profiles>
        <profile>
            <id>src-extra</id>
            <modules>
                <module>src</module>
                <module>child1</module>
                <module>child1</module>
            </modules>
        </profile>
    </profiles>
    

    但是,您还应该调查 --also-make--also-make-depends 选项,这可能允许您做您想做的事,而无需任何 POM 更改或额外的配置文件。

    【讨论】:

    • 基本上我想通过 pom 更改来做到这一点。不是通过命令行。因为我的项目构建在其他项目也构建的服务器中。所有项目都有一个通用的全新安装命令。
    • src 也不是一个模块。 Source 是模块的源文件夹。
    • 不建议混合聚合器模块(带有&lt;modules&gt; 部分的模块)和产生工件的模块。我建议您将child1child2 移动到sub-module1 的同级目录中,并使其依赖于它们。
    猜你喜欢
    • 2012-01-08
    • 2018-05-07
    • 2017-07-09
    • 1970-01-01
    • 1970-01-01
    • 2011-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多