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

Dependency with 'provided' scope has its transitive dependency included in final artifact

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 3.0.4
    • Fix Version/s: None
    • Component/s: Dependencies
    • Labels:
      None
    • Environment:

      Description

      Expected: A dependency declared with a scope of 'provided', along with any transitive dependencies, should not be included in the final artifact.

      Actual: I have a dependency, jsp-api, declared with 'provided' scope. This dependency has a dependency of its own, servlet-api. The servlet-api.jar is being included in the web-inf/lib folder of the resultant war file.

      Background: We recently upgraded from Maven 2.2.1 to Maven 3.0.4. The problem was not witnessed until after the upgrade.

      Steps to Reproduce: Run mvn install, then have a look at the web-inf/lib folder. Notice that the servlet-api.jar has been included.

      Additional Info: It seems that I can only reproduce this behavior when declaring a specific dependency in my pom, spring-ldap. Here is the dependency tree for the given pared-down project (attached):

      — maven-dependency-plugin:2.1:tree (default-cli) @ provided-scope-not-working —
      com.bug.example:provided-scope-not-working:war:0.0.1-SNAPSHOT
      +- javax.servlet:jsp-api:jar:2.0:provided

      - javax.servlet:servlet-api:jar:2.4:provided
      - org.springframework.ldap:spring-ldap:jar:1.2.1:compile
      +- commons-logging:commons-logging:jar:1.0.4:compile
      +- commons-lang:commons-lang:jar:2.1:compile
      +- org.springframework:spring-beans:jar:2.0.6:compile
      +- (commons-logging:commons-logging:jar:1.1:compile - omitted for conflict with 1.0.4)
      - (org.springframework:spring-core:jar:2.0.6:compile - omitted for duplicate)
      - org.springframework:spring-core:jar:2.0.6:compile
      - (commons-logging:commons-logging:jar:1.1:compile - omitted for conflict with 1.0.4)

        Attachments

        1. provided-scope-not-working-shaded.tgz2
          1 kB
          Alexander Courtis [Atlassian]
        2. provided-scope-not-working-jar-only.tgz2
          0.9 kB
          Alexander Courtis [Atlassian]
        3. provided-scope-not-working.zip
          1 kB
          Bart Skondin

          Issue Links

            Activity

              People

              • Assignee:
                jvanzyl Jason van Zyl
                Reporter:
                groovin101 Bart Skondin
              • Votes:
                13 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: