Dependencies 我是否可以将Maven配置为忽略";测试“;如果I';我跳过运行测试?

Dependencies 我是否可以将Maven配置为忽略";测试“;如果I';我跳过运行测试?,dependencies,maven-3,dependency-management,maven-release-plugin,Dependencies,Maven 3,Dependency Management,Maven Release Plugin,我使用的是Maven 3.2.2。在我的一个子模块中,我有这个依赖项 <dependency> <groupId>org.mainco.subco</groupId> <artifactId>core</artifactId> <version>${project.parent.version}</version> <type>t

我使用的是Maven 3.2.2。在我的一个子模块中,我有这个依赖项

    <dependency>
        <groupId>org.mainco.subco</groupId>
        <artifactId>core</artifactId>
        <version>${project.parent.version}</version>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>
我意识到我可以解决构建依赖关系并做好准备的问题,但这个问题特别涉及Maven在我不打算运行任何测试时忽略范围为“测试”的依赖关系


谢谢,-Dave

在Maven开始执行目标之前,它会创建一个构建计划。它将遍历所有依赖项,无论其范围如何。但是,您可以使用由属性触发的配置文件来欺骗它。请注意,配置文件通常用于错误的原因(我注意到prod配置文件,就是这样一个例子:配置不属于工件。这是另一个讨论,关于它有足够的线程)

在这种情况下:

<profile>
  <activation>
    <property>skipTests</property>
    <value>!true<property>
  </activation>
  <dependencies>
  <!-- your test-scoped dependency -->
  </dependencies>
</profile>

滑雪运动员
!真的

因此,是的,它可以,但它可能是更好的,有这个依赖可用。如果其他人签出这段代码并尝试构建它,默认情况下它会失败,对吗?这不是用户所期望的。

您解决了这个问题吗?!true不是有效的xml
<profile>
  <activation>
    <property>skipTests</property>
    <value>!true<property>
  </activation>
  <dependencies>
  <!-- your test-scoped dependency -->
  </dependencies>
</profile>