Maven 2 & 3

Test jar dependency not available for for main classes in multi module builds

Details

  • Complexity:
    Intermediate
  • Testcase included:
    yes
  • Number of attachments :
    1

Description

I have a module layout like this:

root -+- first
      +- second

I have the test-jar plugin enabled, thus a *-tests.jar is built for each module. In the second module, I have defined a dependency to first's tests jar:

       <dependency>
          <groupId>me</groupId>
          <artifactId>first</artifactId>
          <classifier>tests</classifier>
          <version>1.0-SNAPSHOT</version>
          <scope>compile</scope>
       </dependency>

And here's the problem: A class in the second main folder imports a class from the first test folder. If I build the second module separately it builds like it should. But if I build both modules from the root module I get a compilation failure:

/.../root/second/src/main/java/me/SecondMain.java:[3,10] cannot find symbol
symbol  : class FirstTest
location: package me

A class in second's test folder also includes me.FirstTest, and it always compiles. The scope somehow seems to be overridden when doing multi module builds.

Issue Links

Activity

Hide
John Casey added a comment -
Show
John Casey added a comment - See integration test for MNG-2720. It actually reproduces this exact use case. http://svn.apache.org/repos/asf/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2720
Hide
Henrik Brautaset Aronsen added a comment -

Thanks for the updates. As mentioned in the linked issues, this issue is fixable by replacing <classifier>tests</classifier> with <type>test-jar</type>. Just in case anyone else who has this problem sees this issue...

Show
Henrik Brautaset Aronsen added a comment - Thanks for the updates. As mentioned in the linked issues, this issue is fixable by replacing <classifier>tests</classifier> with <type>test-jar</type>. Just in case anyone else who has this problem sees this issue...

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: