When maven builds a jar it places a pom.xml at META-INF///pom.xml. This is the original pom of the artifact. No variables are expanded or inherited and no inherited dependencies are listed. This makes the information of the production jar dependent on the build environment.
How can the pom inside the jar be configured ? Best would be some configuration of the maven-jar-plugin.
I had a similar requirement, as I wanted to get all the information that belongs to the parent pom.xml
. In others words, I wanted to have, in addition to the "raw" pom.xml
, the effective pom inside the JAR generated.
The idea is to use the help:effective-pom
plugin and goal during the generation of the JAR, and put it with the pom.xml
. This is done with this configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>effective-pom</goal>
</goals>
<configuration>
<output>${project.build.outputDirectory}/META-INF/maven/${project.groupId}/${project.artifactId}/effective-pom.xml</output>
</configuration>
</execution>
</executions>
</plugin>
(source)
This is what I really wanted :-) Only I'd like to get rid of the raw pom (which I can't easily see linked question) or trim it somewhat.
reading more of linked questions and answers I found that you can suppress the std pom in the maven-jar-plugin <archive><addMavenDescriptor>false</addMavenDescriptor></archive> and name the effective-pom just pom.