Migrate Maven Release Plugin From 2 to 3

Context: Maven 3 and Maven 4

Maven 3 (and previously 2) provides a default release profile named release-profile that builds and attaches source and javadoc jar: this is defined in the super POM. This profile is activated by default during release:perform with Maven Release Plugin 2.x, unless deactivated by configuring useReleaseProfile parameter to false.

In Maven 4, this default profile will be removed from super POM (see MNG-7029).

To prepare for this removal, Maven Release Plugin 3.0 stopped invoking this profile by default: useReleaseProfile parameter is false by default.

Upgrading Maven Release Plugin 2 to 3

Write And Configure Your Own Release Profile

In order to prepare for Maven 4, each project will instead require to define their own release profile that they'll be able to customise to match their needs:

  • for internal projects, just configure the maven-source-plugin for example
  • for projects published to Maven Central repository, you'll need to add also maven-javadoc-plugin and maven-gpg-plugin: see the documentation.
    Notice: if you already published to Maven Central, there is a good chance the configuration has already been done in a parent POM.

Then configure maven-release-plugin to use that profile during release:perform with releaseProfiles parameter:

<project>
  [...]
  <build>
    [...]
    <plugins>
      [...]
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <releaseProfiles>my-project-release</releaseProfiles>
        </configuration>
      </plugin>
      [...]
    </plugins>
    [...]
  </build>

  [...]

  <profiles>
    <profile>
      <id>my-project-release</id>
      <build>
        <plugins>
         [...
          put here your release-specific plugins invocations, like maven-source-plugin, maven-javadoc-plugin, maven-gpg-plugin, ...
          ...]
        </plugins>
      </build>
    </profile>
    [...]
  </profiles>
</project>

Short Term: Force Using Maven 3-only Default Release Profile

Configuring explicitely useReleaseProfile parameter to true will force Maven Release Plugin 3 to work like version 2.

It provides an easy but temporary solution, working only with Maven 3, when you can't yet write your own release profile.