【问题标题】:How can I make a Maven module only go until the test phase when the parent gets deployed?如何使 Maven 模块只运行到父级部署的测试阶段?
【发布时间】:2015-09-19 17:04:10
【问题描述】:

我正在开发一个多模块项目。我们的模块之一是 tests 项目,它测试其他模块。

第一个问题:这是一个好习惯吗?

Maven 构建生命周期阶段是:

  1. validate
  2. compile
  3. test
  4. package
  5. integration-test
  6. verify
  7. install
  8. deploy

在安装或部署父模块时,如何使tests 模块只运行到test 阶段,即跳过包和后续阶段?因为这个模块的唯一目的是测试其他模块。

【问题讨论】:

  • 您的目标是什么? deploy 目标?
  • @YuriG。是的:当我在我的父母上运行deploy 时,我希望我的tests 项目得到验证、编译和测试,但不打包,也不安装等。

标签: java maven testing build multi-module


【解决方案1】:

我假设它是一个jar 项目。看看Plugin Bindings for Default Lifecycle Reference

maven-jar-pluginmaven-install-pluginmaven-deploy-plugin插件的默认执行绑定到pom.xml中的none阶段

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <id>default-jar</id>
            <phase>none</phase>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.5.2</version>
    <executions>
        <execution>
            <id>default-install</id>
            <phase>none</phase>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.8.2</version>
    <executions>
        <execution>
            <id>default-deploy</id>
            <phase>none</phase>
        </execution>
    </executions>
</plugin>

【讨论】:

  • 也可以在每个插件中使用&lt;configuration&gt;&lt;skip&gt;true&lt;/skip&gt;&lt;/configuration&gt;
  • @sp00m - 是的,没想到。
猜你喜欢
  • 1970-01-01
  • 2023-04-01
  • 2023-01-24
  • 1970-01-01
  • 1970-01-01
  • 2012-07-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多