I have a Maven project with a number of sub modules. Some of these sub modules are packaged as jar that are deployed to a Nexus Maven repository.
The problem I have is that the packaged jar references the parent pom which is not necessarily deployed.
Is there a way for Maven to deploy the effective pom instead of the pom.xml
?
Effective POM combines all the default settings from the super POM file and the configuration defined in our application POM. Maven uses default values for configuration elements when they are not overridden in the application pom.xml.
The Effective POM It is the merge between The Super POM and the POM from The Simplest POM .
xml in C:\MVN\project folder. Now open command console, go the folder containing pom. xml and execute the following mvn command. Maven will start processing and display the effective-pom.
You have to modify your maven configuration to use the desired output folder. Show activity on this post. Edit the pom file and add the folders there. The effective POM file is, as you said, autogenerated on each build, thus also the absolute paths.
You need to be perfectly aware of the consequences of what you want to do: the effective POM will also contain your current settings (content of settings.xml
), thereby possibly publicly exposing whatever passwords you have hard-coded in there. A better solution would be just to deploy the parent POM.
However, if you really want to go down that path, you can have the following configuration:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
<plugin>
<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}/pom.xml</output>
</configuration>
</execution>
</executions>
</plugin>
This tells the maven-jar-plugin
not to add the Maven descriptor pom.xml
and pom.properties
to the jar. Instead, the pom.xml
is generated by the maven-help-plugin
and its effective-pom
goal.
If you want the pom.properties
file also, you will need to create it manually with the maven-antrun-plugin
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With