[ 
http://jira.codehaus.org/browse/MNG-2966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=215621#action_215621
 ] 

Mike Youngstrom commented on MNG-2966:
--------------------------------------

I've done some additional thinking and put together a POC patch.

In my poc patch:

* I've added a step in the model build after the DependencyManagement import 
process.
* I build an effective model for each of the concrete dependencies of the root 
model.
* Any of these optional DependencieManagements I add to the root model I set 
optional=true to differentiate this DependencyManagement Dependency from 
traditional DependencyManagement Dependencies.
 

I believe this approach has the following benefits:
* Allows any dependencies in the root model without versions to be resolved 
along with the other DependencyManagement resolution.
* Since "optional" in a dependencyManagement dependency previously was ignored 
this marker can now be used to identify which DependencyManagement dependencies 
came from DependencyManagement and which came from optional transitive 
dependencies.
* Since these optional DependencyManagements are added after other 
DependencyManagements this should maintain 100% backwards compatibility.

The only concern I have about this approach is the polluting of the 
DependencyManagement of an effective pom that is going on.  So viewing an 
effective pom could have a significantly larger number of dependencies in the 
DependencyManagement section.  Though that can be good too so the developer can 
know what optional dependencies are available to them.

In my prototype I only go one level of dependencies deep.  To match transitive 
dependency semantics I should probably recurse through all transitive levels 
maintaining the same dependency version semantics of transitive dependencies.

Any thoughts about this approach?  I should have a patch ready to post for 
review soon.

Mike

> Use optional transitive dependencies versions as dependencyManagement does
> --------------------------------------------------------------------------
>
>                 Key: MNG-2966
>                 URL: http://jira.codehaus.org/browse/MNG-2966
>             Project: Maven 2 & 3
>          Issue Type: Improvement
>          Components: Dependencies
>    Affects Versions: 2.0.6
>            Reporter: Daniel Beland
>             Fix For: 3.x (to be reviewed)
>
>
> I would like to be able to add an includes statement on a dependency to get 
> its optional dependency(ies).
> ie:
>     <dependency>
>       <groupId>hibernate</groupId>
>       <artifactId>hibernate</artifactId>
>       <version>3.2.1.ga</version>
>       <inclusions>
>         <inclusion>
>           <groupId>jgroups</groupId>
>           <artifactId>jgroups-all</artifactId>
>           <scope>runtime</scope>
>           <optional>false</optional>
>         </inclusion>
>       </inclusions>
>     </dependency>
>  For example, I use hibernate 3.2.1.ga, it has an optional dependency on 
> jgroups-all-2.2.8.
> I would like to be able to add an inclusion statement on the hibernate lib to 
> tell that I want to include jgroups as well. 
> The main reason for this is that I want the same version as specified in the 
> hibernate pom.
> This way, upgrading hibernate would also upgrade my version of jgroups at the 
> same time.
> Obviously, we need to be able to define a scope and optional attribute as 
> well (not inherited)
> Or maybe we could set the dependency explicitly in the pom without specifying 
> the version and have maven resolve the version from the nearest source (as it 
> does normally) automatically or we specify where to resolve it.
> ie something like:
>     <dependency>
>       <groupId>jgroups</groupId>
>       <artifactId>jgroups-all</artifactId>
>       <! -- either maven resolves the version from the nearest source 
> automatically or we need to tell maven where to find it -->
>       <versionLookup>
>         <groupId>hibernate</groupId>
>         <artifactId>hibernate</artifactId>
>         <!-- maven will resolve the version from the hibernate pom as long as 
> hibernate is already a dependency of my project (no version needed)
>                or we specify which version from a property (to have it 
> defined only once in the pom) -->
>         <version>${hibernate.version}</version>
>       </versionLookup>
>       <scope>runtime</scope>
>       <optional>false</optional>
>     </dependency>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to