maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Schulte>
Subject Re: [jira] [Reopened] (MNG-5227) The 'optional' flag of a dependency should be manageable.
Date Fri, 29 Jan 2016 13:23:11 GMT
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=""



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.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message