Hi all,

I've got a classical multi module project with pom inheritance and inter
modules dependencies.
However my modules are always released together and thus have the same
version.
Moreover the whole project is always checkout and the <relativePath> tags
are correctly set.

As a result what I'd like to do is set the version in a single place. Of
course the parent pom seems to be the relevant place.
Let's create a property named <my.version>1.0</my.version> and use it in the
<version> tag of the pom and in the <parent> tag og the child pom.
Call this property in the <dependency> tag too.

An example project is attached:

test0\pom.xml
test0\test1\pom.xml         [jar]
test0\test2\pom.xml         [jar] depends on test 1
test0\sub\pom.xml           [pom]
test0\sub\test3\pom.xml   [jar] depends on test 1

So far, you can successfully test any goal on the root pom.

Now what is really weird is that:
After installing test1-1.0.jar , a compile goal (for example) on test2 fails
because Maven cannot resolve test1-${my.version}!
Everything looks like the ${my.version} property is not set.

To understand what was going on I ran "mvn help:effective-pom" on test2 and
the result is really surprising: the property is correctly set!
I get:
   <dependency>
     <groupId>com.foobar</groupId>
     <artifactId>test1</artifactId>
     <version>1.0</version> <!-- instead of ${ my.version} -->
   </dependency>

Do you have any explanations?
Thanks in advance for your help!

Alexis


ps: in the mergere book, page 261, one can read:
"If a user has specified a property mapping this expression to a specific
value in the current POM, an ancestor POM, or an active profile, it will be
resolved as the
parameter value at this point."

Reply via email to