与Maven共享src / test类,没有test-jar的版本规范 [英] Sharing src/test classes with Maven without version specification for test-jar

查看:170
本文介绍了与Maven共享src / test类,没有test-jar的版本规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在多个模块之间共享src / test类,其方式与附加测试指南以下问题

I'm sharing src/test classes between number of modules, in a similar way described in attaching tests guide and the following question.

因此,我有以下pom.xml依赖项:

So, I have the following pom.xml dependencies:

       <dependency>
            <groupId>com.myco.app</groupId>
            <artifactId>foo</artifactId>
        </dependency>

        <dependency>
            <groupId>com.myco.app</groupId>
            <artifactId>foo</artifactId>
            <version>1.0.0-SNAPSHOT</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

但是,与上述问题相反,在附加测试时 - jar,我不想指定具体的测试jar版本。与编译级依赖关系一样:

BUT, in opposite to the question above, when attaching the test-jar, i don't want to specify the specific test-jar version. As in the compile level dependency:

   <dependency>
      <groupId>com.myco.app</groupId>
      <artifactId>foo</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>

在这种情况下,我的pom.xml会因错误版本的消息而出错。为什么会这样?为什么我可以指定依赖没有版本而不是test-jar?有没有办法克服这个问题,让测试jar使用它能找到的最新jar?

In this case, my pom.xml become erroneous with message about the missing version. Why is this happen? Why i can specify dependency without versions but not the test-jar one? Is there a way to overcome this and make the test-jar to use the latest jar it can find?

推荐答案

之所以如此主代码依赖可以在没有版本的情况下使用,在我们的项目中是否存在主pom,它自动为节中的每个依赖项生成适当的版本。因此,可以在没有特定版本号的情况下指定每个依赖项。

The reason the main code dependency could be used without the version, is the existence of a "main pom" in our project that automatically generates appropriate version for each dependency in section. Therefore, each dependency can be specified without specific version number.

另一方面,测试jar依赖项,没有在传递依赖项中的任何其他地方定义它的版本,所以,必须指定具体版本。

Test-jar dependency on the other hand, don't have it's version defined anywhere else in the transitive dependency so, the specific version must be specified.

这篇关于与Maven共享src / test类,没有test-jar的版本规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆