Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven package effective pom

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?

like image 710
Leon Avatar asked Oct 27 '15 10:10

Leon


People also ask

What is effective POM file?

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.

Where is the effective POM?

The Effective POM It is the merge between The Super POM and the POM from The Simplest POM .

Which command can be used to view effective 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.

Can I edit 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.


1 Answers

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.

like image 56
Tunaki Avatar answered Sep 22 '22 12:09

Tunaki