maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aliaksei Lahachou <aliaksei.lahac...@googlemail.com>
Subject Imported dependency management does not override version and scope defined in parent POM.
Date Mon, 04 Jun 2012 13:09:09 GMT
Hello world!

I encountered an interesting pecularity today. I don't know whether this is
a feature or a bug, intended or not, known or unknown.

Imagine that there are 3 modules:

* Parent - defines version numbers in dependencyManagement and common
plugin configuration in pluginManagement.
* WAR - does not have any versions in dependencies, because versions are
managed in parent.
* Platform - defines platform-specific versions and scopes in
dependencyManagement. For example, JBoss AS 4 is distributed with Javassist
3.8.0 and there can be some problems, when Javassist is contained in WAR.
There are multiple platform modules, but only one is imported at a time.

Parent POM manages the following dependency:

<dependencyManagement>
  <dependendencies>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.6</version>
    </dependency>
  </dependencies>
</dependencyManagement>

Platform POM manages the same dependency:

<dependencyManagement>
  <dependendencies>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.3</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

WAR POM uses the dependency and imports the Platform POM:

<dependencyManagement>
  <dependencies>
    <dependency>
        <groupId>...</groupId>
        <artifactId>platform</artifactId>
        <version>...</version>
        <type>pom</type>
        <scope>import</scope>
  </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
    </dependency>
</dependencies>

What I see is that commons-codec:commons-codec:1.6 is included in final
package. It does not happen if I redefine version and scope directly in WAR
POM:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.3</version>
      <scope>provided</scope>
  </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
    </dependency>
</dependencies>

Versions and scopes from imported Platform POM have effect only if the same
dependency is not defined in Parent. This is kind of unexpected for me,
because documentation states that importing a POM will incorporate all it's
dependencies in importer POM and the result is the same as if dependencies
were defined in the imported POM.

Can someone confirm whether this is a bug or a feature, or whether I do
something wrong. BTW, I use Maven 3.0.3, and the actual project I'm working
on is somewhat more complex.


Regards

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message