Am 01/29/16 um 11:50 schrieb Robert Scholte:
Hi,
What interested me is that is seems to be the intention to NOT manage the
optional flag.[1]
It's one of those issues flagged a regression in Maven 3 which hasn't
been. Maven 2 just did not have support for it. It got removed for Maven
3.0 in 2010 and added to Aether in 2013 without (re-)adding it to Maven
(Aether Bugs 399822 398572 - there are others, if I remember correctly).
Real issue is this nasty bug affecting dependency management in general
- not only the optional flag. Please see this pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>localhost</groupId>
<artifactId>MNG-5227</artifactId>
<version>1-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.3.9</version>
</dependency>
</dependencies>
</project>
The scope of 'commons-lang3' is managed to 'test'. That scope is not
transitive. Executing 'mvn-3.3.9 dependency:tree' (and all other Maven
versions >= 2) incorrectly contains that dependency and produces:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ MNG-5227 ---
[INFO] localhost:MNG-5227:jar:1-SNAPSHOT
[INFO] \- org.apache.maven:maven-model:jar:3.3.9:compile
[INFO] +- org.codehaus.plexus:plexus-utils:jar:3.0.22:compile
[INFO] \- org.apache.commons:commons-lang3:jar:3.4:test
See that 'test' scope. That's just not correct. The transitive 'test'
dependency should not be there since the 'test' scope is not transitive.
With the Aether patch applied executing 'mvn-3.4.0-SNAPSHOT
dependency:tree' now produces the correct graph:
[INFO] --- maven-dependency-plugin:2.9:tree (default-cli) @ MNG-5227 ---
[INFO] localhost:MNG-5227:jar:1-SNAPSHOT
[INFO] \- org.apache.maven:maven-model:jar:3.3.9:compile
[INFO] \- org.codehaus.plexus:plexus-utils:jar:3.0.22:compile
Same for the 'optional' flag. Not having an option to manage the
'optional' flag really is an issue. Either you need to manage it to
'false', to include a transitive dependency flagged optional or you need
to manage it to 'true' to exclude a transitive dependency you do not
need (or which should have been flagged optional but isn't). When Maven
was approaching 3.0, Aether wasn't supporting it.
Regards,
--
Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]