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
    • 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

      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

          Mark Thomas made changes -
          Workflow jira [ 12959574 ] Default workflow, editable Closed status [ 12996497 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 00:05:23 UTC 2015 [ 1428278723217 ]
          Mark Thomas made changes -
          Workflow jira [ 12722020 ] Default workflow, editable Closed status [ 12759452 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 10:31:03 UTC 2015 [ 1428229863560 ]
          Karl Heinz Marbaise made changes -
          Fix Version/s more-investigation [ 20439 ]
          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.
          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...
          Nath made changes -
          Attachment MJAR-138-maven-jar-plugin.patch [ 59786 ]
          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
          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
          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.
          Benjamin Bentmann made changes -
          Field Original Value New Value
          Link This issue is related to MJAR-90 [ MJAR-90 ]
          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.
          Andrew Hughes created issue -

            People

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

              Dates

              • Created:
                Updated:

                Development