简体   繁体   中英

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 ?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM