mojohaus / flatten-maven-plugin

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

<repository> from profile activated via .mvn/maven.config not included in flattened POM #69

Open jglick opened 6 years ago

jglick commented 6 years ago

As of https://github.com/jenkinsci/workflow-basic-steps-plugin/commit/f9f8b16a5b92226bfe868e7f90d2ad04fe1c2af4 if you mvn compile using Maven 3.5.3 you will see a target/copyartifact-1.41-SNAPSHOT.pom which includes

<repositories>
  <repository>
    <id>repo.jenkins-ci.org</id>
    <url>https://repo.jenkins-ci.org/public/</url>
  </repository>
</repositories>

This is missing another repository definition defined in a profile in the parent POM which is activated unconditionally in the child POM based on an entry in .mvn/maven.config. Indeed some of the <dependencies> (in this example workflow-step-api and workflow-api) are found only in that repository.

My intuitive understanding of a flattened POM is that it should include everything another module might need to know in order to consume this artifact; repositories is included because transitive dependencies might be needed. So if a downstream module attempted to depend on this version of workflow-basic-steps, it would by default have dependencies on workflow-step-api and workflow-api, but might not be able to retrieve them unless it itself declared that <repository> (or a ~/.m2/settings.xml did the same).

hohwille commented 5 years ago

To be honest, I was not even aware of the .mvn/maven.config feature. I am using some maven internals to resolve the POM but it seems these maven internals do not care about .mvn/maven.config. You are right that it would be a nice feature enhancement to have at least an option to include this in the flattened POM. Please note that I just created this plugin as a first mover and as a workaround for features IMHO missing in maven. Feel free to provide a PR for this or to make maven core support all this out of the box. However, I do have tons of other OSS projects and am therefore unable to implement every bell and whistle others may want to have.

jglick commented 5 years ago

Oh, understood! For the moment this is not much of a priority I think, but if it becomes one I would certainly try to offer a PR.

hohwille commented 5 years ago

Thanks for your feedback. Still considered as a reasonable feature-enhancement but with lower priority. Still my biggest hope would be some movement in maven core to work on maven 4.x and support consumer POM out of the box making flatten-maven-plugin obsolete.

famod commented 5 years ago

I wouldn't be surprised if this issue has the same root cause as issue #89.