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 ?