[Commented] (MWAR-294) Unwanted transitive dependencies added to the WAR with dependency management and Maven 3.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Commented] (MWAR-294) Unwanted transitive dependencies added to the WAR with dependency management and Maven 3.

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/MWAR-294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16646159#comment-16646159 ]

Marc Rohlfs commented on MWAR-294:

I know that in overlays you must take special care about dependencies vs. libs from base WARs. But that is not the issue here.

The dependencies I don't want to have are given transitively through the _jar-module_ dependency. The _jar-module_ dependency has _provided_ scope and its transitive dependencies must not be added to the resulting WAR artifact (see scope matrix at [Introduction to the Dependency Mechanism - Dependency Scope|https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope]). But in the given project setup they are add.

For further demonstration, I added another dependency _mysql-connector-java_ to the _jar-module_, which is not in the base WAR. It also should not be added to the WAR artifact.

This time, I didn't upload another version of the ZIP file. I provided it the sample project on GitHub now (see a lot easier to me): [https://github.com/marcrohlfs/MWAR-294].

Please test it with +Maven 2.2.1+ and +Maven 3.x+. You'll notice that with Maven +2.2.1+ it works like expected/documented and the unwanted dependencies are not added - but when running the build with +Maven 3.x+, they are added.


> Unwanted transitive dependencies added to the WAR with dependency management and Maven 3.
> -----------------------------------------------------------------------------------------
>                 Key: MWAR-294
>                 URL: https://issues.apache.org/jira/browse/MWAR-294
>             Project: Maven WAR Plugin
>          Issue Type: Bug
>    Affects Versions: 2.1.1, 2.3
>         Environment: Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
> Maven home: /opt/apache-maven-3.0.4
> Java version: 1.6.0_26, vendor: Sun Microsystems Inc.
> Java home: /usr/lib/jvm/java-6-sun-
> Default locale: en_GB, platform encoding: UTF-8
> OS name: "linux", version: "2.6.32-43-generic", arch: "i386", family: "unix"
>            Reporter: Marc Rohlfs
>            Priority: Major
>             Fix For: more-investigation
>         Attachments: MWAR-294-updated.zip, MWAR-294.zip
> With Maven 3, unwanted libraries are added to the _WEB-INF/lib_ folder of the packed web app in a multi-module build if:
> * The WAR module has a JAR dependency with {{provided}} scope.
> * The POM of the WAR module (or its parent POM) has a {{dependencyManagement}} section that defines the transitive dependencies of the JAR module.
> * The dependencies in the {{dependencyManagement}} section are *not* defined as dependencies of the WAR module.
> * The dependencies in the {{dependencyManagement}} section explicitly define {{compile}} or {{runtime}} scope.
> This leads to unwanted dependencies in the packaged web app or even duplicate dependencies when using overlays.
> When running the build with _Maven 2.2.1_, it works fine and doesn't add those unwanted dependencies to the web app.

This message was sent by Atlassian JIRA