You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stevo Slavić <ss...@gmail.com> on 2009/10/15 13:55:58 UTC

Maven 3 and transitive dependency exclusion replacements

Hello Maven users,

In Maven 3 it will hopefully be possible to define global dependency
exclusions <http://jira.codehaus.org/browse/MNG-1977>. Question is will it
be possible to specify transitive dependency exclusion replacements, local
and/or global?

Here is one example case where I think this would be useful:
spring-security-core v2.0.x module is built against spring framework 2.0.x
and depends on its artifacts, some of which have been reorganized and/or
renamed in 2.5.x. If then application depends on both spring framework 2.5.x
and spring security 2.0.x, duplicate modules (backwards compatible, yet with
different maven artifactId) will unnecessarily be present.

With Maven 2 one can in dependencyManagement section specify dependency
exclusion (for spring-security's transitive dependencies to spring 2.0.x),
but can not specify their effective replacements at same place - if I'm not
mistaken, instead I have to spread that dependency replacement info all over
the multi-module project pom's. For a non-reporting plugin one can specify
exclusions and add dependencies but not for a dependency.

Regards,
Stevo.

Re: Maven 3 and transitive dependency exclusion replacements

Posted by Stevo Slavić <ss...@gmail.com>.
Thanks Barrie,

Nice idea and workaround. Nevertheless it's not the same as if one could
specify added dependencies (replacements) along with exclusions in
dependencyManagement section.

Regards,
Stevo.

On Mon, Oct 26, 2009 at 2:10 AM, Barrie Treloar <ba...@gmail.com> wrote:

> On Thu, Oct 15, 2009 at 10:25 PM, Stevo Slavić <ss...@gmail.com> wrote:
> [del]
> > With Maven 2 one can in dependencyManagement section specify dependency
> > exclusion (for spring-security's transitive dependencies to spring
> 2.0.x),
> > but can not specify their effective replacements at same place - if I'm
> not
> > mistaken, instead I have to spread that dependency replacement info all
> over
> > the multi-module project pom's. For a non-reporting plugin one can
> specify
> > exclusions and add dependencies but not for a dependency.
>
> I may be wrong with this, but I think a way to work around this issue
> is to create a "dependency project" (I'm not sure if that's the
> correct term).
>
> The only purpose for this project is to define all the dependencies in
> one place and then where you need this "group" of dependencies your
> project depends upon the "dependency project".
>
> The "dependency project" has a packaging of pom.
>
> e.g.
> We use WebLogic 10 for our applications, but WebLogic is not built
> with Maven so there is no dependency information.  After spending
> hours chasing down the full jar list and the installing them locally
> we created a WebLogic 10 "dependency project". It would look something
> like this:
>
> <project>
>  <groupId>weblogic</groupId>
>  <artifactId>weblogic-dependencies</artifactId>
>  <version>10.0.0</version>
>  <packaging>pom</packaging>
>  ...
>  <dependencies>
>    <dependency>
>      <groupId>weblogic</groupId>
>      <artifactId>weblogic</artifactId>
>      <version>10.0.0</version>
>      <!-- Note: these would normally be scope=provided as they are
> part of the weblogic runtime -->
>    </dependency>
>    <dependency>
>      <groupId>weblogic</groupId>
>      <artifactId>javax.jms_1.1</artifactId>
>      <version>10.0.0</version>
>    </dependency>
>    <dependency>
>      <groupId>weblogic</groupId>
>      <artifactId>javax.servlet_2.5</artifactId>
>      <version>10.0.0</version>
>    </dependency>
>    ...
>  </dependencies>
> </project>
>
> Then any projects that want to use these dependencies include this
> project like any other normal dependency.
> Via transitive dependencies you pull in everything but have only had
> to write it once.
>
> You can do the same for your Spring projects.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Maven 3 and transitive dependency exclusion replacements

Posted by Barrie Treloar <ba...@gmail.com>.
On Thu, Oct 15, 2009 at 10:25 PM, Stevo Slavić <ss...@gmail.com> wrote:
[del]
> With Maven 2 one can in dependencyManagement section specify dependency
> exclusion (for spring-security's transitive dependencies to spring 2.0.x),
> but can not specify their effective replacements at same place - if I'm not
> mistaken, instead I have to spread that dependency replacement info all over
> the multi-module project pom's. For a non-reporting plugin one can specify
> exclusions and add dependencies but not for a dependency.

I may be wrong with this, but I think a way to work around this issue
is to create a "dependency project" (I'm not sure if that's the
correct term).

The only purpose for this project is to define all the dependencies in
one place and then where you need this "group" of dependencies your
project depends upon the "dependency project".

The "dependency project" has a packaging of pom.

e.g.
We use WebLogic 10 for our applications, but WebLogic is not built
with Maven so there is no dependency information.  After spending
hours chasing down the full jar list and the installing them locally
we created a WebLogic 10 "dependency project". It would look something
like this:

<project>
  <groupId>weblogic</groupId>
  <artifactId>weblogic-dependencies</artifactId>
  <version>10.0.0</version>
  <packaging>pom</packaging>
  ...
  <dependencies>
    <dependency>
      <groupId>weblogic</groupId>
      <artifactId>weblogic</artifactId>
      <version>10.0.0</version>
      <!-- Note: these would normally be scope=provided as they are
part of the weblogic runtime -->
    </dependency>
    <dependency>
      <groupId>weblogic</groupId>
      <artifactId>javax.jms_1.1</artifactId>
      <version>10.0.0</version>
    </dependency>
    <dependency>
      <groupId>weblogic</groupId>
      <artifactId>javax.servlet_2.5</artifactId>
      <version>10.0.0</version>
    </dependency>
    ...
  </dependencies>
</project>

Then any projects that want to use these dependencies include this
project like any other normal dependency.
Via transitive dependencies you pull in everything but have only had
to write it once.

You can do the same for your Spring projects.

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


Re: Maven 3 and transitive dependency exclusion replacements

Posted by Stevo Slavić <ss...@gmail.com>.
Missed comment<http://jira.codehaus.org/browse/MNG-1977?focusedCommentId=194430&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_194430>in
global dependency exclusions issue discussion, it points to related
exlcusion
replacements issue <http://jira.codehaus.org/browse/MNG-4391>.

Regards,
Stevo.

On Thu, Oct 15, 2009 at 12:55 PM, Stevo Slavić <ss...@gmail.com> wrote:

> Hello Maven users,
>
> In Maven 3 it will hopefully be possible to define global dependency
> exclusions <http://jira.codehaus.org/browse/MNG-1977>. Question is will it
> be possible to specify transitive dependency exclusion replacements, local
> and/or global?
>
> Here is one example case where I think this would be useful:
> spring-security-core v2.0.x module is built against spring framework 2.0.x
> and depends on its artifacts, some of which have been reorganized and/or
> renamed in 2.5.x. If then application depends on both spring framework 2.5.x
> and spring security 2.0.x, duplicate modules (backwards compatible, yet with
> different maven artifactId) will unnecessarily be present.
>
> With Maven 2 one can in dependencyManagement section specify dependency
> exclusion (for spring-security's transitive dependencies to spring 2.0.x),
> but can not specify their effective replacements at same place - if I'm not
> mistaken, instead I have to spread that dependency replacement info all over
> the multi-module project pom's. For a non-reporting plugin one can specify
> exclusions and add dependencies but not for a dependency.
>
> Regards,
> Stevo.
>