首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven模块将不会使用scalatest找到依赖项。

Maven模块将不会使用scalatest找到依赖项。
EN

Stack Overflow用户
提问于 2014-11-05 12:36:14
回答 1查看 679关注 0票数 1

当我和最严重的人一起工作时,我遇到了一个奇怪的问题。我有一个包含多个模块的maven项目。如果我直接在模块中执行mvn test。它可以正常工作,但是如果我在根文件夹中这样做,它会在编译时抱怨缺少包(依赖项)。

我的配置如下所示:

代码语言:javascript
复制
    <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>

插件配置:

代码语言:javascript
复制
          <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.退出

代码语言:javascript
复制
        <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>

对我做错了什么有什么想法吗?!

干杯

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-05 20:02:08

很难说,如果没有看到所有的dependencyManagement,但通常情况下:在根Pom中定义所有依赖项在pluginManagement部分,插件在pluginManagement部分中定义它们的配置。在子poms中,只定义所需的插件和依赖项。

请记住,xxxManagement部分只构建共享定义,这是一种根配置。您仍然需要在插件和依赖项部分定义所需的内容,但可以省略版本和配置元素。

这将允许您的所有子poms在所有模块中运行测试。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26757373

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档