Sharing src / test classes with Maven without spec specification for test jar

I share the src / test classes between the number of modules described in the same way in the attached testing guide and the next question .

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> 

BUT , in contrast to the above question, when attaching a test jar, I do not want to indicate a specific version of the test banner. As depending on the compilation level:

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

In this case, my pom.xml will become erroneous with a message about the missing version. Why is this happening? Why can I specify a dependency without versions , but not a test jar? Is there a way to overcome this and get the test jar to use the last jar it can find?

+2
java maven maven-3
Aug 20 '15 at 13:27
source share
1 answer

The reason that the main code dependency can be used without a version is the presence of a โ€œmain pumpโ€ in our project, which automatically generates the corresponding version for each dependency in the section. Therefore, each dependency can be specified without a specific version number.

The dependency of the test jar, on the other hand, does not have its version defined elsewhere in the transitive dependency, so you need to specify a specific version.

+2
Aug 24 '15 at 9:53 on
source share



All Articles