I am trying to use maven 3.0 system dependencies.
In a maven 3.0 project called projectA, in the pom.xml, I have the following
dependency setup:
<dependency>
<groupId>a.b.c</groupId>
<artifactId>common-util<artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${abc.install}/lib/common-util.jar</systemPath>
</dependency>
If I define the abc.install variable in the <properties> section of the
projectA pom.xml or in the pom.xml of a parent maven project (inheritance) or
even in my settings.xml (in a specific profile that is activated), the
compilation of my project works just fine as expected.
The issue is if I have another maven project, let's call it projectB, that is
dependent from this one.
If the abc.install variable is declared in the projectA pom.xml, no issues,
things are still working just fine.
But if the abc.install variable is declared in the pom.xml of the projectA
parent or in my settings.xml, when building projectB, I get the following
warning (and error in debug mode):
[WARNING] The POM for projectA:xyz:jar:1.0 is invalid, transitive dependencies
(if any) will not be available: 1 problem were encountered while building the
effective model for projectA:xyz:jar:1.0
[ERROR] 'dependencies.dependency.systemPath' for projectA:xyz:jar must specify
an absolute path but is ${abc.install}/lib/common-util.jar
It is like if the abc.install variable was not resolved any longer as soon as
it is found through a project dependency (unless it is defined in the pom.xml).
The problem is that it breaks the transitive dependencies completely.
If projectA has other dependencies (that are not system dependencies), maven
will not do transitive dependencies for these when building projectB.
Only option I found so far (short of defining abc.install in projectA pom.xml)
is to define abc.install as a -D option to the maven command.
A bit more background on what I am trying to do that will explain why I would
like to use system dependencies and be able to specific in a single place
(ideally settings.xml) the property value(s) used to resolved these system
dependencies:
- I want to put in place a set of maven projects to test a given product
installation
- Since I need to test a specific product installation, I want to point
directly to all the jar files of that specific product installation so I am
100% sure that I am actually testing what has been installed. This is why I
want to use the maven system dependency.
- I also want to be able to very quickly switch from one product installation
to another (think automated QA suite) which means that I want to be able to
define in a single place (settings.xml through one or more profiles) the
location of that installation
- I was thinking that I could simply specify in my settings.xml the location of
the product installation to test and then all the system dependencies would be
resolved from that definition. That part is actually working as expected but if
I start having dependencies between my different test projects (which I
definitely need to do some code sharing between the different tests), then the
transitive dependency mechanism is broken.