0

I assumed for a long time that the distributionManagement tag was required for the maven release plugin because it needs to know where to upload the released artifacts. But to some extent this is true. If I configure my pom.xml like this, maven complains about missing distributionManagement:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.github.nbauma109</groupId>
    <artifactId>jd-util</artifactId>
    <version>1.0.16-SNAPSHOT</version>
    <scm>
        <connection>scm:git:https://github.com/nbauma109/jd-util.git</connection>
        <developerConnection>scm:git:ssh://git@github.com/nbauma109/jd-util.git</developerConnection>
        <url>https://github.com/nbauma109/jd-util</url>
        <tag>HEAD</tag>
    </scm>
</project>

The error is the following:

Error: 5,765 [INFO] 15:33:25,764 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project jd-util: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
Error: 5,765 [INFO] 15:33:25,764 [ERROR] 
Error: 5,765 [INFO] 15:33:25,764 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: 5,765 [INFO] 15:33:25,764 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
Error: 5,765 [INFO] 15:33:25,764 [ERROR] 
Error: 5,765 [INFO] 15:33:25,764 [ERROR] For more information about the errors and possible solutions, please read the following articles:
Error: 5,765 [INFO] 15:33:25,764 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
15:33:25,784 [INFO] ------------------------------------------------------------------------
15:33:25,784 [INFO] BUILD FAILURE
15:33:25,784 [INFO] ------------------------------------------------------------------------
15:33:25,786 [INFO] Total time:  14.696 s
15:33:25,786 [INFO] Finished at: 2022-02-05T15:33:25Z
15:33:25,786 [INFO] ------------------------------------------------------------------------
Error: 5,791 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:perform (default-cli) on project jd-util: Maven execution failed, exit code: '1' -> [Help 1]
Error: 5,791 [ERROR] 
Error: 5,791 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: 5,791 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
Error: 5,791 [ERROR] 
Error: 5,791 [ERROR] For more information about the errors and possible solutions, please read the following articles:
Error: 5,792 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I found that it's possible to skip the deploy stage with the property maven.deploy.skip=true like in this answer https://stackoverflow.com/a/23222265/8315843 or by configuring the plugin:

https://maven.apache.org/plugins/maven-deploy-plugin/faq.html

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-deploy-plugin</artifactId>
  <version>X.Y</version>
  <configuration>
    <skip>true</skip>
  </configuration>
</plugin>

However, this isn't even necessary. If I just explicitly configure the release plugin with the same version that was picked up by default (i.e., version 2.5.3), it stops complaining about the distributionManagement.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.github.nbauma109</groupId>
    <artifactId>jd-util</artifactId>
    <version>1.0.16-SNAPSHOT</version>
    <scm>
        <connection>scm:git:https://github.com/nbauma109/jd-util.git</connection>
        <developerConnection>scm:git:ssh://git@github.com/nbauma109/jd-util.git</developerConnection>
        <url>https://github.com/nbauma109/jd-util</url>
        <tag>HEAD</tag>
    </scm>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <tagNameFormat>@{project.version}</tagNameFormat>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

What's going on here ?

Sybuser
  • 735
  • 10
  • 27
  • 1
    The distributionManagement is not really needed by the maven-release-plugin. It's needed by the maven-deploy-plugin. Indirectly it is needed by the default maven-release-plugin which implies to call `mvn deploy`... This can be overwritten if you like. Check: https://maven.apache.org/maven-release/maven-release-plugin/perform-mojo.html#goals – khmarbaise Feb 05 '22 at 22:37
  • I think I got confused somewhere as both examples fail. Either we need to skip deploy in the deploy plugin, either configure goals install in maven release plugin. – Sybuser Feb 06 '22 at 05:59
  • 1
    If you configure `install` in maven release plugin this will work. Skipping the deploy can be a way too... – khmarbaise Feb 06 '22 at 08:33

1 Answers1

0

I got confused in my first anaylsis.

Basically there are 2 options :

  • Configure the release plugin to set the goals to install (comment from @khmarbaise and also his older answer):

https://stackoverflow.com/a/59917365/8315843

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <configuration>
    <arguments>${arguments}</arguments>
    <goals>install</goals>
    <autoVersionSubmodules>true</autoVersionSubmodules>
    </configuration>
</plugin>
  • Configure the deploy plugin to skip the deploy step :

https://maven.apache.org/plugins/maven-deploy-plugin/faq.html

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-deploy-plugin</artifactId>
  <version>X.Y</version>
  <configuration>
    <skip>true</skip>
  </configuration>
</plugin>
Sybuser
  • 735
  • 10
  • 27