You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Trevor Torrez <ja...@gmail.com> on 2007/04/25 19:10:24 UTC

commons-logging dependency

I'm trying to eliminate commons-logging from being transitively passed
on to projects that depend on my library and my library uses spring.
Spring uses commons-logging but doesn't mark it as optional or
scope:provided, however when I try to exclude commons logging from a
spring dependency, I no longer get it even though it is declared in my
pom.

Here's a simple pom which exposes the problem (maven 2.0.4):

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>some.groupid</groupId>
  <artifactId>blah</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>blah</name>
  <url>http://maven.apache.org</url>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>avalon-framework</groupId>
          <artifactId>avalon-framework</artifactId>
        </exclusion>
        <exclusion>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
        </exclusion>
        <exclusion>
          <groupId>logkit</groupId>
          <artifactId>logkit</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-dao</artifactId>
      <version>2.0</version>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
</project>

Now if you remove the commons-logging exclusion from the spring-dao
dependency, commons-logging get correctly pulled down.  Also note that
this problem does NOT surface if I use spring-context even though the
poms appear to be practically identical.

Whats going on?

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


Re: commons-logging dependency

Posted by Trevor Torrez <ja...@gmail.com>.
The problem arises when "blah" is used as a dependency in a downstream
project that is not using commons logging at all (ie, slf4j); since
that project will not have commons logging as a dependency it gets
resolved and included in the project from the transitive dependency on
spring-dao.  Since it is not known why this is happening, is the only
solution to have every project either exclude it from just about every
framework dependency or declare it but never both?

Did global transitive dependency exclusions make it into the feature
set of maven?

On 4/25/07, Wendy Smoak <ws...@gmail.com> wrote:
> On 4/25/07, Trevor Torrez <ja...@gmail.com> wrote:
> > I'm trying to eliminate commons-logging from being transitively passed
> > on to projects that depend on my library and my library uses spring.
> > Spring uses commons-logging but doesn't mark it as optional or
> > scope:provided, however when I try to exclude commons logging from a
> > spring dependency, I no longer get it even though it is declared in my
> > pom.
>
> You don't need the exclusion.  Just declare commons-logging 1.1 and
> that will override the version coming from Spring.
>
> --
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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


Re: commons-logging dependency

Posted by Wendy Smoak <ws...@gmail.com>.
On 4/25/07, Trevor Torrez <ja...@gmail.com> wrote:
> I'm trying to eliminate commons-logging from being transitively passed
> on to projects that depend on my library and my library uses spring.
> Spring uses commons-logging but doesn't mark it as optional or
> scope:provided, however when I try to exclude commons logging from a
> spring dependency, I no longer get it even though it is declared in my
> pom.

You don't need the exclusion.  Just declare commons-logging 1.1 and
that will override the version coming from Spring.

-- 
Wendy

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