Hi,

there are two subtle differences between Maven 2.x and 3.x regarding POM interpolation I would like to discuss.

a) Ordering of Interpolation Sources

According to section 6.1 of the POM spec for Maven 3.x, the precedence of interpolation sources is:

  1. Maven Props
  2. System Props
  3. POM Props
  4. Environment Props

In particular, system properties dominate POM values, i.e. "mvn package -Dproject.version=0.1" will override the project version as given in the POM. This is different compared to Maven 2.x where model values can't be overriden by system properties.

As far as I understand 3.x, the reasoning for the above ordering is that "POM Props" include both reflective data from the model and the values from the <properties> section (which, I agree, should be dominated by system props).

IMHO, there should be no way to override model values to ensure a reliable degree of independence from the environment. Hence I suggest the handle model values and the <properties> section as independent interpolation sources, i.e.

  1. Maven Props (e.g. basedir)
  2. Model Values
  3. System Props
  4. <properties> section
  5. Environment Props

b) Resolution of Expressions

Consider this POM snippet:

  <properties>
    <project.prop>A</project.prop>
    <prop>B</prop>
    <foo>C</foo>
  </properties>
  <name>${project.prop} - ${prop} - ${foo}</name>

If there was a "Maven certified developer", a nice question for his exam could be "What is the effective value of the <name> element?".

Well, in Maven 2.x it's "B - B - C". In Maven 3.x, it's "A - B - C".

The first "B" in the Maven 2.x answer results from the interpolator stripping the "project.|pom." prefix from "project.prop" when querying the <properties> section.

IMHO, here is Maven 3.x making a nicer job. "Nice" here means more intuitive and more consistent. With "consistent" I refer to the behavior of the PluginParameterExpressionEvaluator that does not strip any prefixes from expressions when resolving them from the <properties> section.

If we agree that the current Maven 2.x way to handle an expression that is prefixed with project.|pom. but doesn't match a model value is odd, can we change/fix this behavior for Maven 2.1.x and even Maven 2.0.x?


Benjamin


P.S.: For those that sill wonder what YAPII means: "Yet Another POM Interpolation Issue". Sorry, but I was in strange mood.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to