Maven efficient pom package

I have a Maven project with several additional modules. Some of these auxiliary modules are packaged in jars that are deployed to the Nexus Maven repository.

The problem is that the packaged jar refers to the parent pom, which is not necessarily deployed.

Is there a way for Maven to deploy an efficient pom instead pom.xml?

+4
source share
1 answer

You need to be aware of the consequences of what you want to do: an effective POM will also contain your current settings (contents settings.xml), thereby possibly publicly revealing all the passwords that you hard-coded there. A better solution would be to simply deploy the parent POM .

However, if you really want to go this route, 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>

It says maven-jar-pluginnot to add Maven handle pom.xml and pom.propertiesinto the jar. Instead, and is pom.xmlgenerated .maven-help-plugineffective-pom

If you need a file pom.properties, you will need to create it manually using maven-antrun-plugin.

+6
source

Source: https://habr.com/ru/post/1613331/


All Articles