Type: New Feature
Resolution: Won't Fix
Affects Version/s: None
Fix Version/s: None
The pom.xml has dual purpose.
1. Building and distributing a jar
2. Used by another project for dependency management.
For #1 build and distribution, pom.xml makes good sense with many sections and hierarchies. In this case the main objective is dealing with sources and various aspects of build.
For #2, lets say project B needs the jar produced by project A ( #1), the only things B needs from A are,
1. jar files
2. dependencies of this jar file
For #2 use-case, none of the sections or hierarchies of pom.xml make sense, except for <dependencies>.sections and GAV.
Unfortunately maven simply copies the same pom.xml used for build to the repository for distribution.
This problem gets complicated when there are pom hierarchies and <dependencyManagement> sections
In such cases, to resolve the dependencies of an artifact, maven needs to use more than one pom.xml. This results in complex release and patch process and potential build time issues.
Enhance the maven deploy plugin to deploy a "flattened" pom that contains only GAV and <dependencies> section.
The <dependencies> section contains, properly resolved direct dependencies of the artifact, which are the same of "pom hierarchy" direct dependencies.
"flattened" pom means it cannot have any parent or any other sections that are not necessary while deploying the artifact.
Note that we may need to add removeMetadata method to org.apache.maven.artifact.Artifact interface to remove the original pom metadata and then add the "flattened" pom metadata. I have created jira issue http://jira.codehaus.org/browse/MNG-5544 for this function
1. "mvn deploy" could deploy "flatten" pom onto maven repo and its "flatten" pom's dependencies version should be the same as versions of "pom hierachy".
2. "flatten" pom only contains GAV and <dependencies> section.
3. "flatten" pom only contains original direct dependencies, not including transitive dependencies.
4. "flatten" pom won't inherit from any parent pom.
5. "flatten" pom is only for artifact whose packaging is jar.