why is “test-jar” dependency required for “mvn compile”

后端 未结 4 1482
名媛妹妹
名媛妹妹 2021-02-02 13:38

I\'m having trouble using test-jar dependencies in a multi-module project. For example, when I declare that the cleartk-syntax module depends on the

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-02 14:16

    This looks like a definite bug to me.

    I have the same problem and tested Maven 3.0.1 and 3.0.2. Validate doesn't fail, only the compile step fails. With Maven 3 mvn compile breaks but mvn test-compile works.

    It appears that the compile phase is looking for test-jar artifacts in the reactor and then repo, but it shouldn't since the dependency is in test scope. Test scope artifacts should be resolved during test-compile, not compile.

    As a result, I thought this could be worked around by mapping the maven-compiler-plugin's testCompile goal to the compile phase, instead of the default test-compile phase.

    I added this to my pom, right next to the part that adds the test-jar creation in the upstream pom:

      
      
        maven-compiler-plugin
        
          
            default-testCompile
            compile
            
              testCompile
            
          
        
      
    

    But that won't work either because the five phases between compile and test-compile haven't run and set up things like the test classpath.

    I guess the real workaround until this bug is fixed is to use test-compile in place of compile.

提交回复
热议问题