I have a question regarding properties in a multi-module project.
Consider the following 3-level project struture:
project
+- pom.xml (packaging: pom) //referred to as super-pom
+- module_group
+- pom.xml (packaging: pom) //referred to as group-pom
+- module
+-pom.xml (packaging: jar) //referred to as module-pom
In the super-pom I define a property revision which gets the default value "unknown".
Additionally I declare and use the buildnumber-maven-plugin
which is configured to get the svn revision and put it into property revision.
Next I configure the maven-jar-plugin
to write that property into the manifest.
In th module-pom I declare usage of the buildnumber-maven-plugin
so that is actually executed.
This all works when building the module directly, i.e. executing the module-pom only.
The manifest contains the revision that is reported by the buildnumber-maven-plugin
as is printed in the console.
However, if I execute the super-pom or group-pom the default value for revision is written to the manifest, although the buildnumber-maven-plugin
gets executed and it retrieves the correct revision (it prints it to the console before the maven-jar-plugin
runs).
So I have the feeling that I am missing something on property inheritance in multi-module projects.
Does anyone have an idea what could be wrong here? Or could anyone point me to a description of how properties are actually handled in those cases (unfortunately I didn't manage to find a good description yet)?
Update
I did some research and a few test runs with debug output (-X
option) and from what I found so far, I assume my problem is the following:
1) During pom parsing the properties used in the pom are replaced with their values.
Consider this partial pom:
<!-- declare the property default value -->
<properties>
<revision>default</revision>
</properties>
...
<!-- use the property -->
<someconfig>${revision}</someconfig>
After the pom is evaluated, it seems to result in a state that would correspond to this:
<properties>
<revision>default</revision>
</properties>
...
<!-- The property seems to be "statically" replaced -->
<someconfig>default</someconfig>
2) The plugin that sets the actual property value runs afterwards, even if during the validate
phase.
Thus the property itself is correctly set to the new value, but it is not read anymore.
3) The plugin that uses <someconfig>
(in my case it would be the maven-jar-plugin
) now runs with <someconfig>default</someconfig>
and thus it doesn't read revision
at all.
Can anyone confirm this?