Hello,
I have a problem with the import-scope & dependency management (Maven 3.0.3).
There are 3 pom's involved.
The first is a 'ju-deps' dependency pom, merely used to encapsulate versions of
third party libs.
[code]
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myself</groupId>
<artifactId>ju-deps</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>ju-deps</name>
<properties>
<junit.version>4.8.1</junit.version>
</properties>
<dependencies>
<!--- #1 : if one specifies the test scope in this dependency
pom, the test sources will not compile !!! -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<!--scope>test</scope-->
</dependency>
</dependencies>
</project>
[/code]
The second one is a parent project. In this project I use a dependency
management section (so that child projects do not need to specify a version).
I 'import' the ju-deps pom. Is this a correct scope?
[code]
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myself</groupId>
<artifactId>parentapp</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<modules>
<module>sampleapp</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.myself</groupId>
<artifactId>ju-deps</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
[/code]
The third one is a 'sampleapp' child project, that provides a test class (so it
needs a dependency to ju-deps).
[code]
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.myself</groupId>
<artifactId>parentapp</artifactId>
<version>1.0</version>
</parent>
<artifactId>sampleapp</artifactId>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
<!-- #2. If one specifies a pom inside
dependency management, one needs to give the version,
although the version was specified in the dependency
management section of the parent.
[ERROR] The
project com.myself:sampleapp:1.0 (D:\tryout\import\sampleapp\pom.xml) has 1
error
[ERROR]
'dependencies.dependency.version' for com.myself:ju-deps:pom is missing. @ line
16, column 21-->
<dependency>
<groupId>com.myself</groupId>
<artifactId>ju-deps</artifactId>
<!--version>1.0</version-->
<type>pom</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
[/code]
There are 2 problems (indicated in the pom source).
#1 : if one specifies a test scope in a dependency pom, the test sources in the
sampleapp child project do not get (test-)compiled correctly. This seems
something I can live with.
#2 : If one specifies a dependent pom in a child project, one needs to give the
version, although the version was specified in the dependency management
section of the parent. What am I doing wrong here?
Regards,
Luc