You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Michael Osipov (JIRA)" <ji...@apache.org> on 2018/05/10 17:07:00 UTC

[jira] [Closed] (MNG-6406) Dependency order : Depending on transitive version instead of declared based on order of declaration

     [ https://issues.apache.org/jira/browse/MNG-6406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Osipov closed MNG-6406.
-------------------------------
    Resolution: Not A Problem

There are two issues not observed here and the aforementioned commit is not a complete fix:

1. The Servet API **must** always be in scope {{provided}} because it must not be deployed with the app, but is provided by the servlet container
2. Both artifacts are distinct becasue they have disjointed artifact id. Both need to have {{provided}}, but when b uses a, it must explicitly exclude version 2.5 for completeness.

> Dependency order : Depending on transitive version instead of declared based on order of declaration
> ----------------------------------------------------------------------------------------------------
>
>                 Key: MNG-6406
>                 URL: https://issues.apache.org/jira/browse/MNG-6406
>             Project: Maven
>          Issue Type: Bug
>         Environment: mvn -v 
> Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-14T04:10:27+08:00)
> Maven home: /home/cp/...../apache-maven-3.3.1
> Java version: 1.8.0_121, vendor: Oracle Corporation
> Java home: /home/cp/...../oracle-jdk-1.8.0_121/jre
> Default locale: en_SG, platform encoding: UTF-8
> OS name: "linux", version: "4.4.0-122-generic", arch: "amd64", family: "unix"
>            Reporter: Chandra Prakash
>            Priority: Minor
>
> h3. *Overview :* 
> The order of dependency declaration in the pom is taking precedence instead of depth.  Check this sample : https://github.com/ProcrastinatorCp/maven-dependency-issue-poc
> h3. *Example Scenario :* 
> There are two modules. *test-a* and *test-b*
> *test-a* (depends on javax.servlet-api:2.5)
> *test-b* (depends on test-a)
> I want to use 3.1.0 version of above library in test-b. However, if test-a is declared before ***javax.servlet-api*, executing *mvn clean package* fails. 
> {code:xml}
> <!-- NG : Reads 2.5 version of javax.servlet-api -->
> <dependency>
> <groupId>com.cp.test</groupId>
> <artifactId>test-a</artifactId>
> <version>${com.cp.test.version}</version>
> </dependency>
> <dependency>
> <groupId>javax.servlet</groupId>
> <artifactId>javax.servlet-api</artifactId>
> <version>3.1.0</version>
> </dependency>
> {code}
> If I change the ordering, it works fine. 
> {code:xml}
> <!-- OK : Reads 3.1.0 version of javax.servlet-api -->
> <dependency>
> <groupId>javax.servlet</groupId>
> <artifactId>javax.servlet-api</artifactId>
> <version>3.1.0</version>[link title|http://example.com]
> </dependency>
> <dependency>
> <groupId>com.cp.test</groupId>
> <artifactId>test-a</artifactId>
> <version>${com.cp.test.version}</version>
> </dependency>
> {code}
> The documentation at : 
> [https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html]
>  > the current pom's declaration takes precedence over its parent's declaration.
> However, current pom declaration is not taking precedence *when ordered differently* (as above pom)
> Could you please confirm. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)