Maven JAR Plugin
  1. Maven JAR Plugin
  2. MJAR-138

jar:test-jar is skipped when maven.test.skip=true

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3.1
    • Fix Version/s: more-investigation
    • Component/s: None
    • Labels:
      None
    • Environment:
      jar:test-jar
    • Number of attachments :
      1

      Description

      Not sure if this is a bug or improvement...

      Example:

      • ./pom.xml
      • ./moduleA/pom.xml
      • ./moduleB/pom.xml

      Situation:

      • moduleA produces moduleA-1.2.3-test.jar with the jar:test-jar goal
      • moduleB consumes moduleA-1.2.3-test.jar as a <dependency>...<scope>test</scope><dependency>

      Problem:

      • When -Dmaven.test.skip=true the moduleA-1.2.3-test.jar is never built.
      • Then when moduleB tries to build, it's moduleA-1.2.3-test.jar dependency is unresolved. FAIL! Even with -Dmaven.test.skip=true this will fail.

      You might argue that this is a bug with dependency resolution with -Dmaven.test.skip=true - should a missing dependency @ test scope really fail the build??? It probably should - which is why the bug is submitted here

      I've no idea what could be done to fix this either?

      p.s. for anyone with this bug the only workaround I can suggest is running another module...

      ./moduleA-test/pom.xml

      and have <dependency>...<artifactId>moduleA-test<artifactId>...<scope>test</scope></dependency>

        Issue Links

          Activity

          Hide
          Benjamin Bentmann added a comment -

          maven.test.skip=true suppresses multiple things: test compilation, test execution and test jar packaging. The later was intentionally done as per MJAR-90.

          Independently how this should be addressed in the future, for now a simple workaround is to use skipTests=true instead. This suppresses test execution only, but produces a proper test-jar which allows other modules to both properly resolve their dependencies and even compile against those.

          Show
          Benjamin Bentmann added a comment - maven.test.skip=true suppresses multiple things: test compilation, test execution and test jar packaging. The later was intentionally done as per MJAR-90 . Independently how this should be addressed in the future, for now a simple workaround is to use skipTests=true instead. This suppresses test execution only, but produces a proper test-jar which allows other modules to both properly resolve their dependencies and even compile against those.
          Hide
          Sofia Paiva added a comment - - edited

          Hi,

          I have the same problem.

          If i use maven.test.skip=true, the dependency is not found and the build fails. If i use skipTests=true, the jar-test is produced, but integration-tests are executed.

          I agree with Andrew that a test dependency shouldn't fail the build.

          Show
          Sofia Paiva added a comment - - edited Hi, I have the same problem. If i use maven.test.skip=true , the dependency is not found and the build fails. If i use skipTests=true , the jar-test is produced, but integration-tests are executed. I agree with Andrew that a test dependency shouldn't fail the build.
          Hide
          Nath added a comment -

          I do agree that in some situations it should be down to the dependency resolution to skip "test" scope dependencies if we specify maven.test.skip.
          But for now we can utilise the forceCreation configuration setting within the maven-jar-plugin to forcefully create the test-jars even if maven.test.skip is specified by applying the following patch.

          Show
          Nath added a comment - I do agree that in some situations it should be down to the dependency resolution to skip "test" scope dependencies if we specify maven.test.skip. But for now we can utilise the forceCreation configuration setting within the maven-jar-plugin to forcefully create the test-jars even if maven.test.skip is specified by applying the following patch.
          Hide
          Nath added a comment -

          Patch to allow <forceCreation>true</forceCreation> to create test-jar package even if maven.test.skip = true

          Show
          Nath added a comment - Patch to allow <forceCreation>true</forceCreation> to create test-jar package even if maven.test.skip = true
          Hide
          Rene Grob added a comment -

          If -Dmaven.test.skip=true skips the test compilation why is maven complaining about missing dependencies that are of scope TEST? There's something wrong with that...

          Show
          Rene Grob added a comment - If -Dmaven.test.skip=true skips the test compilation why is maven complaining about missing dependencies that are of scope TEST? There's something wrong with that...
          Hide
          Ivan Bondarenko added a comment - - edited

          The same situation (version 2.4) and need the same feature. Nath's patch is Ok for us.

          P.S. Actually setting skip=false is also good as explicit value has a priority.

          Show
          Ivan Bondarenko added a comment - - edited The same situation (version 2.4) and need the same feature. Nath's patch is Ok for us. P.S. Actually setting skip=false is also good as explicit value has a priority.

            People

            • Assignee:
              Unassigned
              Reporter:
              Andrew Hughes
            • Votes:
              10 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated: