BiG*_*GzZ 7 dependencies maven
我正在开发一个使用maven进行建筑的项目.我想要做的是跳过测试依赖.基本上运行maven构建,而我的maven存储库中没有工件.
例如
<artifactId>example</artifactId>
<scope>test</scope>
Run Code Online (Sandbox Code Playgroud)
这是来自我项目的pom文件,我必须在没有工件示例的情况下构建我的项目.
我搜索过使用"-DskipTests = true"或"-Dmaven.test.skip = true"等解决方案.在我的情况下,他们确实跳过了测试的运行,但它仍然抱怨缺少依赖文件.
有没有人知道运行maven构建的方法而不必在maven存储库中有测试工件?
谢谢.
请参阅https://issues.apache.org/jira/browse/MNG-4192。我认为解决这个问题的唯一方法是将测试范围的依赖项移至 Maven 配置文件中。
这是一个例子:
<profile>
<id>test-with-extra-dependency</id>
<dependencies>
<dependency>
<groupId>org.example.groupid</groupId>
<artifactId>artifact-id</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
Run Code Online (Sandbox Code Playgroud)
您现在应该能够在没有测试的情况下运行构建:
mvn clean install -Dmaven.test.skip=true -DskipTests=true
Run Code Online (Sandbox Code Playgroud)
之后,您可以在启用配置文件的情况下运行测试:
mvn test --activate-profiles test-with-extra-dependency
Run Code Online (Sandbox Code Playgroud)
我不建议这样做,但这在当前模块和测试依赖项之间存在循环依赖项的情况下非常有用,即您可以构建模块,然后使用构建结果构建测试依赖项,最后使用测试依赖性。如果您发现自己想要这样做,请尝试重组您的项目以消除循环依赖(例如,通过将测试移动到第三个模块)。
归档时间: |
|
查看次数: |
2690 次 |
最近记录: |