mojohaus / flatten-maven-plugin

Flatten Maven Plugin
https://www.mojohaus.org/flatten-maven-plugin/
Apache License 2.0
200 stars 85 forks source link

flatten-maven-plugin is ignoring explicit set properties #65

Open Helpstone opened 6 years ago

Helpstone commented 6 years ago

Assume a pom.xml with properties like this:

<properties>
      <build.number>manual</build.number>
      <label>build.${build.number}</label>
</properties>

When calling maven with mvn -Dbuild.number=123, I would expect to get the following properties in the flattened-pom

<properties>
      <build.number>123</build.number>
      <label>build.123</label>
</properties>

But what I get is

<properties>
      <build.number>manual</build.number>
      <label>build.123</label>
</properties>

I did not peek into the code, but probably the properties are retrieved with project.getProperties() only, which do reflect explicit set properties for substitutions only, but not in their own definition. So session.getUserProperties() should be used for overwritten properties.

khmarbaise commented 6 years ago

Which Maven version do you use?

Helpstone commented 6 years ago

Maven 3.5.2 and flatten-maven-plugin 1.0.1

hohwille commented 5 years ago

Seems like an obvious bug. We should test this with the latest version and add an IT for it. If this bug is still present, we need to fix it.

hohwille commented 5 years ago

I did not read carefully enough. Currently we are only interpolating variable expressions (${...}) on flattening. What you are expecting is that a child element from properties will also be overridden from commandline. I still see your expectation as this is also what happens during the maven build and it is a valid feature request, but it is not an obvious bug as I thought in the first place.