eip*_*ark 1 java eclipse testing maven
我试图在测试期间在另一个 Maven 模块中使用 test-jar 依赖项。因此,就像在这个问题(多模块项目中的 Maven 测试依赖项)和 Maven 指南中一样,我在模块 A 中放置了一个 test-jar 目标,并在模块 B 中放置了对其的依赖项,我想在其中使用 A 中的一些类在我的测试中。Eclipse 可以正确识别我的所有类,当我从项目根目录运行全新安装,然后mvn dependency:tree在模块 B 中运行时,我会看到模块 A。
然而,当我运行 时mvn clean install,maven 抱怨说
... package 'my.package.in.module.A' does not exist
Run Code Online (Sandbox Code Playgroud)
我的项目的结构是
reactor
--module A
--module B
Run Code Online (Sandbox Code Playgroud)
波姆A:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
...
Run Code Online (Sandbox Code Playgroud)
波姆B:
...
<dependency>
<groupId>com.company.moduleA</groupId>
<artifactId>module-A</artifactId>
<version>moduleA-version</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
为了隐私,我省略了版本/工件/等,但它们匹配正确。
我错过了什么吗?
编辑:这可能不是这个问题的正确解决方案,但我只是删除了它<type>test-jar</type>并在不使用它的情况下让它工作。
小智 7
有一个解决方法。使用 -DskipTests 代替 maven.test.skip。第二个也跳过测试的编译,因此不会创建测试 jar。
请参阅http://maven.apache.org/plugins/maven-surefire-plugin/examples/skipping-test.html
| 归档时间: |
|
| 查看次数: |
2869 次 |
| 最近记录: |