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

Optional true getting lost in managed dependencies when transitive

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.9
    • Fix Version/s: 3.5.2
    • Component/s: Dependencies
    • Labels:
      None
    • Environment:

      Description

      Run 'mvn package' on the project in the attached Parent.zip. Note that the dependency Jar2 gets packaged in WEB-INF/lib and the other dependencies (Jar, Jar1 and Jar3) do not.

      I think the inclusion of Jar2 is incorrect, because project 'Web' declares its dependency on 'Jar' to be optional and Jar2 being a transitive dependency of Jar should inherit this.

      If you look at the other Jarx dependencies, they have different combinations of ways to become optional and have their versions managed. Only the case when optionality is inherited and the dependency management for the version is in another pom, yields incorrect results.

      Please note that I believe the maven-war-plugin is not the cause of this behavior. I have built and used a modified version of maven-war-plugin which as the first thing in its WarMojo.execute() lists the result of getProject().getArtifacts() including the value of each Artifact's isOptional() method. Already at this point only Jar2 has optional false.

      I am using maven-war-plugin in this bug report for the following reasons:

      • maven-war-plugin uses the optional flag of dependencies in deciding whether to package it or not, making this behavior visible
      • I don't know of another way to visualize the value of the optional flag in core maven (running with -X outputs the dependency tree in a section with header 'Dependency collection stats', but this only shows the scope value)
      • maven-dependency-plugin:resolve also only shows scope and not optionality
      • obviously, maven-war-plugin is exactly what I intend to use and where I found the bug
      1. Parent.zip
        4 kB
        Marcel Schutte
      2. buildoutput.txt
        255 kB
        Marcel Schutte

        Issue Links

          Activity

          Hide
          mschutte Marcel Schutte added a comment -

          Sample project demonstrating my problem and output of running

          mvn -X package

          Show
          mschutte Marcel Schutte added a comment - Sample project demonstrating my problem and output of running mvn -X package
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in maven-3.x #1216 (See https://builds.apache.org/job/maven-3.x/1216/)
          MNG-5935 Optional true getting lost in managed dependencies when (schulte: rev 184f58ff83a6d043c695a07f1b1ae89630f6bc9e)

          • maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
          • maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in maven-3.x #1216 (See https://builds.apache.org/job/maven-3.x/1216/ ) MNG-5935 Optional true getting lost in managed dependencies when (schulte: rev 184f58ff83a6d043c695a07f1b1ae89630f6bc9e) maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
          Hide
          mschutte Marcel Schutte added a comment -

          Thanks for fixing this, I can confirm that my issue is resolved in the february 11 maven 3.4.0-SNAPSHOT build

          Show
          mschutte Marcel Schutte added a comment - Thanks for fixing this, I can confirm that my issue is resolved in the february 11 maven 3.4.0-SNAPSHOT build
          Hide
          stephenc Stephen Connolly added a comment -

          Maven 3.4.0 has been dropped. See this thread for more details.

          This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.

          Show
          stephenc Stephen Connolly added a comment - Maven 3.4.0 has been dropped. See this thread for more details. This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.
          Hide
          schulte77 Christian Schulte added a comment -

          Issue is fixed in the master branch of my private maven repository on github. When interested, you can cherry pick the commit to your own repository and create a pull request for the apache master branch with just this commit yourself from there.

          Show
          schulte77 Christian Schulte added a comment - Issue is fixed in the master branch of my private maven repository on github . When interested, you can cherry pick the commit to your own repository and create a pull request for the apache master branch with just this commit yourself from there.
          Hide
          stephenc Stephen Connolly added a comment -

          Seems like this is a bug that should be possible to include in scope for 3.5.1

          Show
          stephenc Stephen Connolly added a comment - Seems like this is a bug that should be possible to include in scope for 3.5.1
          Hide
          michael-o Michael Osipov added a comment -

          Stephen, I agree. Though this needs an IT because I do not understand the subtile fix for it.

          Show
          michael-o Michael Osipov added a comment - Stephen, I agree. Though this needs an IT because I do not understand the subtile fix for it.
          Hide
          michael-o Michael Osipov added a comment -

          I just triead Christian's patch with MSHARED-437, it exactly depicts the issue. With a bit work we will even have a proper IT for that.

          Show
          michael-o Michael Osipov added a comment - I just triead Christian's patch with MSHARED-437 , it exactly depicts the issue. With a bit work we will even have a proper IT for that.
          Show
          michael-o Michael Osipov added a comment - Fixed with f4ede96fd06c8d3e1e2b2fb679baec058cce30e1 and IT with 4aeb411456ba9b0c5a3baadb552736ffbc57da51 .
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-3.x #1650 (See https://builds.apache.org/job/maven-3.x/1650/)
          MNG-5935 Optional true getting lost in managed dependencies when (michaelo: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=f4ede96fd06c8d3e1e2b2fb679baec058cce30e1)

          • (edit) maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
          • (edit) maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-3.x #1650 (See https://builds.apache.org/job/maven-3.x/1650/ ) MNG-5935 Optional true getting lost in managed dependencies when (michaelo: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=f4ede96fd06c8d3e1e2b2fb679baec058cce30e1 ) (edit) maven-core/src/main/java/org/apache/maven/RepositoryUtils.java (edit) maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java

            People

            • Assignee:
              michael-o Michael Osipov
              Reporter:
              mschutte Marcel Schutte
            • Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development