Maven 2 & 3

Property inheritance when filtering with multiple profiles is gone

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 2.0.9
  • Fix Version/s: 2.0.9
  • Component/s: Profiles
  • Labels:
    None
  • Complexity:
    Intermediate
  • Number of attachments :
    1

Description

pom.xml:
<build>
<filters>
<filter>default.properties</filter>
</filters>
</build>
<profiles>
<profile>
<id>first</id>
<build>
<filters>
<filter>first.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>second</id>
<build>
<filters>
<filter>second.properties</filter>
</filters>
</build>
...
default.properties:
prop=

first.properties:
prop=first_value

second.properties:
other_prop=${prop}

since 2.0.9 the value of

other_prop

is not replaced and is written as ${prop}, instead of inherit the value 'first_value', when executing

mvn -Pfirst,second process-resources

This breaks existing configurations badly and I do not see a workaround whithout losing the ability to configure in more than one dimension, which makes mvn 2.0.9 quite unsuable for project requirements in real life.

Activity

Hide
Martin Buechler added a comment -

unzip and compare target/classes/test.properties when executing

<yourpath-to>/apache-maven-2.0.8/bin/mvn -Pfirst,second clean process-resources

and

<yourpath-to>/apache-maven-2.0.9/bin/mvn -Pfirst,second clean process-resources

Show
Martin Buechler added a comment - unzip and compare target/classes/test.properties when executing <yourpath-to>/apache-maven-2.0.8/bin/mvn -Pfirst,second clean process-resources and <yourpath-to>/apache-maven-2.0.9/bin/mvn -Pfirst,second clean process-resources
Hide
Martin Buechler added a comment -

The problem exists only if empty values are inherited, which can be quite always eliminated by avoiding to rely on empty values.

Show
Martin Buechler added a comment - The problem exists only if empty values are inherited, which can be quite always eliminated by avoiding to rely on empty values.
Hide
Martin Buechler added a comment - - edited

Doh, forgot to test it with 2.0.9 and with non empty values, and . . . of course it IS a major bug in 2.0.9.

Show
Martin Buechler added a comment - - edited Doh, forgot to test it with 2.0.9 and with non empty values, and . . . of course it IS a major bug in 2.0.9.
Hide
Martin Buechler added a comment -

The findings:

mvn 2.0.9 uses per default

maven-resources-plugin-2.2
maven-war-plugin-2.1-alpha-1

while

mvn 2.0.8 uses per default

maven-resources-plugin-2.3
maven-war-plugin-2.1-alpha-2

this is pretty weird, since the newer version uses the older plugins.

To get the behaviour of mvn 2.0.8. into 2.0.9 one has to provide explicit versions for both plugins in

a parent pom's pluginmangement section like

...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-alpha-2</version>
</plugin>
</plugins>
</pluginManagement>
...

or directly at the plugin definition.

Show
Martin Buechler added a comment - The findings: mvn 2.0.9 uses per default maven-resources-plugin-2.2 maven-war-plugin-2.1-alpha-1 while mvn 2.0.8 uses per default maven-resources-plugin-2.3 maven-war-plugin-2.1-alpha-2 this is pretty weird, since the newer version uses the older plugins. To get the behaviour of mvn 2.0.8. into 2.0.9 one has to provide explicit versions for both plugins in a parent pom's pluginmangement section like ... <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.3</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1-alpha-2</version> </plugin> </plugins> </pluginManagement> ... or directly at the plugin definition.
Hide
Benjamin Bentmann added a comment -

Clarification:
Maven versions before 2.0.9 do not provide default versions for the plugins, this is a new feature introduced in Maven 2.0.9 (MNG-3395). Previously, you just got LATEST for any plugin whose version was not explicitly specified. LATEST being quite subject to time and other environmental aspects, this is a suboptimal choice for anybody seeking reproducible builds.

Moral:
Always specify the desired version for each and every plugin your build uses.

Show
Benjamin Bentmann added a comment - Clarification: Maven versions before 2.0.9 do not provide default versions for the plugins, this is a new feature introduced in Maven 2.0.9 (MNG-3395). Previously, you just got LATEST for any plugin whose version was not explicitly specified. LATEST being quite subject to time and other environmental aspects, this is a suboptimal choice for anybody seeking reproducible builds. Moral: Always specify the desired version for each and every plugin your build uses.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: