You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Neale (JIRA)" <ji...@codehaus.org> on 2009/10/13 15:31:27 UTC

[jira] Issue Comment Edited: (MNG-4391) DependencyManagement should allow to manage use of re-named, woven, instrumented or compatible artifacts

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

Neale edited comment on MNG-4391 at 10/13/09 8:30 AM:
------------------------------------------------------

I think that's a rather personal point of view, if you don't mind me saying.  On that basis, none of us would make use of AspectJ or proxies.

It is _already_ the case that a child project configured to download X gets Y, as that's what we're actually trying to do.  The problem is that it doesn't actually say "replace X with Y".  It says: "don't download X".

You are mistaken in thinking that "when I look at the child POM, it says download X" is relevant to what we as developers need.  We can easily end up with multiple versions of the same API on the classpath because the exclusions weren't set on every child.

At some point in our project we want to say something like (as OSGi gives us): _the implementation of org.apache.commons.logging that I want to use in my build and runtime can be found in org.slf4j:slf4j:org.apache.commons.logging_, or, if we want one that has been built as a valid OSGi bundle: _org.slf4j:com.springsource.slf4j.org.apache.commons.logging_.

What we certainly *don't* want is to have to repeat the exclude on an ad-hoc basis, and nor do we want the _meaning_ lost in separating out an exclusion with a global inclusion (which is not always wanted either - e.g. for corporate standards).

Can you please tell me how you propose to satisfy this use case, if you still have your objections to my solution. It's all very well disagreeing, but it would be useful to offer a better solution in it's place.

      was (Author: neale87):
    I think that's a rather personal point of view, if you don't mind me saying.  On that basis, none of us would make use of AspectJ or proxies.

It is _already_ the case that a child project configured to download X gets Y, as that's what we're actually trying to do.  The problem is that it doesn't actually say "replace X with Y".  It says: "don't download X".

You are mistaken in thinking that "when I look at the child POM, it says download X" is relevant to what we as developers need.  We can easily end up with multiple versions of the same API on the classpath because the exclusions weren't set on every child.

At some point in our project we want to say something like (as OSGi gives us): _the implementation of org.apache.commons.logging that I want to use in my build and runtime can be found in org.slf4j:slf4j:org.apache.commons.logging_, or, if we want one that has been built as a valid OSGi bundle: _org.slf4j:com.springsource.slf4j.org.apache.commons.logging_.

What we certainly *don't* want is to have to repeat the exclude on an ad-hoc basis, and nor do we want the _meaning_ lost in separating out an exclusion with a global inclusion (which is not always wanted either - e.g. for corporate standards).

Can you please tell me how you propose to satisfy this use case, if you still have your objections to my solution, please. It's all very well disagreeing, but it would be useful to offer a better solution in it's place.
  
> DependencyManagement should allow <replaceWith> to manage use of re-named, woven, instrumented or compatible artifacts
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: MNG-4391
>                 URL: http://jira.codehaus.org/browse/MNG-4391
>             Project: Maven 2
>          Issue Type: Improvement
>          Components: Dependencies
>    Affects Versions: 2.2.1
>            Reporter: Neale
>
> [if only this was a later version of JIRA I'd have not lost all of what I just typed, as I could use Mylyn instead of the web UI.  here goes again...]
> The challenge of using a different artifact instead of the one that is specified in a POM that you are consuming is not an easy one.
> Examples where this hits uses is:
> - the artifact name and packaging changes that Spring made at 2.5.6A (which was a big improvement)
> - wanting to use SLF4J instead of Apache commons logging (i.e. use something that provides the same API, but is an entirely different project)
> - wanting to use your own derivation of a public artifact
> - wanting to use a woven/instrumented version of a public artifact
> The current approach to replacing, say org.springframework : spring-beans with org.springframework : org.springframework.beans is to do ('scuse the shorthand):
> {code:xml}
> <dependencyManagement>
>   <dependencies>
>     <dependency>
>       <groupId>com.sun.jersey.contribs</groupId>
>       <artifactId>jersey-spring</artifactId>
>       <exclusions> 
>            org.springframework : spring-beans
>       </exclusions>
>     </dependency>
>     ... repeat for every artifact that uses spring-beans, and then add more if adding another artifact
>   </dependencies>
> </dependencyManagement>
> {code}
> to exclude it, and then globally include the replacement using:
> {code:xml}
> <dependencies>
>   <dependency>
>     <groupId>org.springframework</groupId>
>     <artifactid>org.springframework.beans</groupId>
>     <version>${spring.version}</version>
>   </dependency>
> </dependencies>
> {code}
> This is error prone, and could be made far easier by an extension to dependencies, which would remove the need to know what artifacts (jersey-spring in the above example) use the artifact that you are replacing.  Here's how it would look:
> {code:xml}
> <dependencyManagement>
>   <!-- this declares the version we want to use if this artifact is in use -->
>   <dependencies>
>     <dependency>
>       <groupId>org.springframework</groupId>
>       <artifactid>org.springframework.beans</groupId>
>       <version>${spring.version}</version>
>     </dependency>
>     <!-- This deals with artifact name change -->
>     <dependency>
>       <groupId>org.springframework</groupId>
>       <artifactid>spring-beans</groupId>
>       <replaceWith>  <!-- list of dependency elements -->
>           <dependency>
>             <groupId>org.springframework</groupId>
>             <artifactid>org.springframework.beans</groupId>
>           </dependency>
>           <!-- more dependency elements could be added here if an artifact has been split -->
>       </replaceWith>
>     </dependency>
> </dependencies>
> {code}
> NOTE:
> - Nothing is specified in <dependencies> so no artifacts are globally added where they may not be needed.  This means we can develop a project wide parent pom.xml.
> - Artifacts can have been split and merged
> - Derived artifacts, such as instrumented ones can easily be substituted, and could be selectively substituted using profiles.

-- 
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