mojohaus / flatten-maven-plugin

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

Proposal: add codes to parse the <version> for the dependency in profile which is managed by <dependencyManagement> when the <activation> is <jdk> or <os> #148

Open yangnuoyu opened 4 years ago

yangnuoyu commented 4 years ago

Problem: Connecting to the question #145 , we cannot fetch dependency versions in when it is managed by dependencyManagement in the parent pom. I notice that there is a embedBuildProfileDependencies configuration which is mentioned in #138 . When we set it as true, the plugin will parse the profile but just works when activation is not "jdk" or "os". So it is still a problem when we want to use either of them. The key problem is that, when dealing with profile in a pom, the flatten-maven-plugin just copies the profile to effectivePom but not parse it.

Proposal: Add a piece of code to parse the version of the dependencies in profile after creating the effectivePom which will be used in most of the flatten modes.

I personally use a straightforward method to solve the problem: when effectivePom is created, it has both dependencyManagement part and profile part. I write a code to go through both of their dependencies to find matches, if so, I will copy the version from dependencyManagement to the dependency in profile if it does not have a version.

I have tested it in different flatten modes and it always works, but I think it will be more stable if we can use existing functions in Java Maven.

stephaniewang526 commented 4 years ago

@saturnism @olamy @lasselindqvist @rfscholte please let us know your thoughts

olamy commented 4 years ago

LGTM