Open sleicht opened 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).
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.
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.
I finally could reproduce my initial problem. It happens if the profile with dependency is located in a parent project. See PR #21.
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.
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.
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?
.divisionpom/spring-boot
and .divisionpom/spring-boot-2
) to include one of the two profiles with different dependency sets. (yes, I know this is not the way Maven wishes to do things but avoiding replicas of dependency definitions in several hundred projects was worth the mess right now ;-)).flatten:flatten
does not take the parent profiles into account and ends with
4536 [ERROR] Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.2.0-SNAPSHOT:flatten (default-cli) on project mamido-shared-jnlp-connect: 3 problems were encountered while building the effective model for com.unitedinternet.mamido:mamido-shared-jnlp-connect:1.0-SNAPSHOT
4537 [ERROR] [WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ com.unitedinternet.mamido:mamido-shared-jnlp-connect:[unknown-version], /Users/USER/ws/git.example.com/mamido/mamido-shared/jnlp-connect/pom.xml
4538 [ERROR] [ERROR] 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter:jar is missing. @
4538 [ERROR] [ERROR] 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-test:jar is missing. @
I started debugging this (I will push the branch soon) and did not succeed :-(
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.
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