Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-4032

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

    XMLWordPrintableJSON

Details

    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.

      Attachments

        1. tests-dependency.zip
          5 kB
          Henrik Brautaset Aronsen

        Issue Links

          Activity

            People

              jdcasey John Dennis Casey
              henrik242 Henrik Brautaset Aronsen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: