maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Boué <gb...@apache.org>
Subject Re: Scope promotion of managed dependencies in current Maven master
Date Mon, 19 Dec 2016 19:27:15 GMT
Hi Michael,

I can reproduce that behaviour as well. In the current 3.4.0, a 
dependency management that declares a dependency with scope runtime will 
manage a transitive dependency of scope test. A reproducer is

   <dependencyManagement>
     <dependencies>
       <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-simple</artifactId>
         <version>1.7.21</version>
         <scope>runtime</scope>
       </dependency>
     </dependencies>
   </dependencyManagement>
   <dependencies>
     <dependency>
       <groupId>test</groupId>
       <artifactId>test</artifactId>
       <version>1.0-SNAPSHOT</version>
     </dependency>
   </dependencies>

And having in the POM of test:

   <dependencies>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
       <version>1.7.21</version>
       <scope>test</scope>
     </dependency>
   </dependencies>

This doesn't feel right to me: dependencies of scope test are not 
transitive, so the test scoped slf4j-simple shouldn't be considered 
during dependency resolution. I wouldn't also expect the 
dependencyManagement to change the scope of the inherited slf4j-simple 
(if it were to be inherited), since there are definite rules about which 
scope a transitive dependency should have depending on the scope of the 
declared dependency (summarized in the table here 
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope).

Guillaume

Le 19/12/2016 à 15:56, Michael Osipov a écrit :
> Hi folks,
>
> I just tried a fresh Maven master (7d1d8ac0c14bdea6c92356436bfc6f8548cbae8b; 2016-12-19T15:22:22+01:00)
> on an in-house project.
>
> My project's parent POM states in depMgmt:
>
> <dependency>
>    <groupId>org.slf4j</groupId>
>    <artifactId>slf4j-api</artifactId>
>    <version>${slf4j.version}</version>
> </dependency>
> <dependency>
>    <groupId>org.slf4j</groupId>
>    <artifactId>jcl-over-slf4j</artifactId>
>    <version>${slf4j.version}</version>
>    <scope>runtime</scope>
> </dependency>
> <dependency>
>    <groupId>org.slf4j</groupId>
>    <artifactId>slf4j-simple</artifactId>
>    <version>${slf4j.version}</version>
>    <scope>runtime</scope>
> </dependency>
>
> nothing special so far, a WAR module dependends on net.sf.michael-o.dirctxsrc:dircontextsource:jar:1.3:compile
> which has slf4j-simple in *test* scope. mvn dependency:tree with 3.3.9 properly gives
me:
>
> [DEBUG]    net.sf.michael-o.dirctxsrc:dircontextsource:jar:1.3:compile
>
> Doing this with master gives me:
>
> [DEBUG]    net.sf.michael-o.dirctxsrc:dircontextsource:jar:1.3:compile
> [DEBUG]       org.slf4j:slf4j-simple:jar:1.7.21:runtime (scope managed from test by com.company.project:project-parent:0.11-SNAPSHOT)
>
> My questions are:
> 1. Is this another fix in master where I relied on an erratic behavior in core previously?
> 2. Should depMgmthave influence on transitive deps or direct only?
>
> I cannot really say what's right or wrong but now I have two SLF4J bindings on my WAR
classpath:
> SLF4J Simple and Logback, now that is obviously wrong!
>
> Any thoughts?
>
> Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>


---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus
Avast.
https://www.avast.com/antivirus


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Mime
View raw message