mojohaus / flatten-maven-plugin

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

Parent profiles missing in flattened pom #14

Open sleicht opened 8 years ago

sleicht commented 8 years ago

Profiles with dependencies are not written into the flattened pom as described here: http://www.mojohaus.org/flatten-maven-plugin/flatten-mojo.html (Element: profiles). Profiles doesn't get processed as the profileInjector does nothing: https://github.com/mojohaus/flatten-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java#L649

hohwille commented 8 years ago

The profile injector does nothing on purpose. The referenced code is only to build the effective POM. The actual flattened POM is then build from the effective POM and the maven project with the configured strategies merging things. Did you set embedBuildProfileDependencies? What is your Profile? The purpose of flatten-maven-plugin is to create portable and reproduceable POMs that do not depend on variables. Please describe your use-case. It might turn out that this is by design not supported and we need a discussion if that should be supported or not. A POM in the central maven repo should not depend on external properties. I assume you have a POM with packaging pom that you are flattening. This is not a regular use-case (so far).

hohwille commented 8 years ago

Maybe your point is that if someone defines a profile with dependencies and the invokes the build with -P myprofile then the profile might not be triggered such that its dependencies do not go into the flattened pom. If that is actually the case, I will agree that this is a bug that we should create an IT for and then fix it.

hohwille commented 8 years ago

I added new ITs to cover additional profile scenarios and they all work as expected. See also existing ITs such as os-profile-active and os-profile-inactive that entirely keep the profile section in the flattened POM what is actually the default. I will close this as invalid. Feel free to comment additional details and/or provide an IT to prove any bug. I do not see anything wrong here.

sleicht commented 8 years ago

I finally could reproduce my initial problem. It happens if the profile with dependency is located in a parent project. See PR #21.

sleicht commented 8 years ago

Additionally: In the docs for the property embedBuildProfileDependencies it is written that leaving this to false all profiles will stay in the flattened-pom. So I would expect to see the profile with dependency in the flattened pom, but thats not what happens.

hohwille commented 8 years ago

OK. I can now confirm that the effective POM calculation is wrong about inherited profiles as even with ElementHandling.expand the profile is not inherited to flattened POM.

hohwille commented 5 years ago

Can someone shed some light into this? PR #21 is merged. It was providing integration test to reproduce the problem. AFAIK the ITs are all proceeding without errors (otherwise travis would fail and the release would have been blocked). So is this already fixed?

mfriedenhagen commented 5 years ago

I started debugging this (I will push the branch soon) and did not succeed :-(

kwin commented 3 years ago

I tried with manually setting the parameter pomElements.

None of <profiles>expand</profiles>, <profiles>keep</profiles> or <profiles>interpolate</profiles> made the parent pom profiles appear in the flattened pom.xml. This is crucial though for using flatten-maven-plugin with packaging pom

Also help:effectivePom is not exposing the non-active profiles.