当我和最严重的人一起工作时,我遇到了一个奇怪的问题。我有一个包含多个模块的maven项目。如果我直接在模块中执行mvn test。它可以正常工作,但是如果我在根文件夹中这样做,它会在编译时抱怨缺少包(依赖项)。
我的配置如下所示:
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.shortversion}</artifactId>
<version>3.0.0-SNAP2</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
</dependency>插件配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
</configuration>
<executions>
<execution>
<id>scala-test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>如果我从maven-scala-plugin中移除goals,它将编译,但scalatest将找不到测试源并使用No tests were executed.退出
<plugin>
<version>2.15.2</version>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>对我做错了什么有什么想法吗?!
干杯
发布于 2014-11-05 20:02:08
很难说,如果没有看到所有的dependencyManagement,但通常情况下:在根Pom中定义所有依赖项在pluginManagement部分,插件在pluginManagement部分中定义它们的配置。在子poms中,只定义所需的插件和依赖项。
请记住,xxxManagement部分只构建共享定义,这是一种根配置。您仍然需要在插件和依赖项部分定义所需的内容,但可以省略版本和配置元素。
这将允许您的所有子poms在所有模块中运行测试。
https://stackoverflow.com/questions/26757373
复制相似问题