Fork me on GitHub

Usage

Add the plugin to your pom:

<build>
    <plugins>
        <plugin>
            <groupId>com.github.danielflower.mavenplugins</groupId>
            <artifactId>multi-module-maven-release-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <releaseGoals>
                    <releaseGoal>deploy</releaseGoal>
                </releaseGoals>
            </configuration>
        </plugin>
    </plugins>
</build>

And then call the plugin:

mvn releaser:release

You can also optionally supply your own build numbers if you do not want an automatically incrementing number:

mvn releaser:release -DbuildNumber=1234

Running a partial release

It is possible to release a single module (and any modules it depends on) by using the modulesToRelease parameter. For example:

mvn releaser:release -DmodulesToRelease=MyApp

In this case the MyApp module will be built, released and tagged. If MyApp depends on another module, than that module will also be built and released (but there will be no Git tag for this).

Note that this is not generally required as the plugin will only deploy changed modules by default anyway.

Forcing a release

It is possible to force the release of one or more specified modules, for example if the changes have not been picked up due to some issue. To do this, use the forceRelease parameter. For example:

mvn releaser:release -DforceRelease=MyApp

In this case the MyApp module will be built, even if there where no changes found.

Specify custom global/user Maven settings for release build

Sometimes it's necessary to specify custom Maven settings for the release build. This can be done with the following standard maven command line parameters:

mvn releaser:release -s /path/to/custom/user/settings.xml -gs /path/to/custom/global/settings.xml

Authentication

Please see SSH Authentication or HTTPS Authentication.

Determining which modules have changed

When determining which modules have changed since the previous release, the previously built artifacts must be available. Artifacts can be in a local or remote maven repository. If the previously built artifacts are not available, all modules will be considered changed.

Version reports

Version report generation is supported for both the released modules (version incremented) and non-released modules (latest version).

The supported report formats are FLAT(line separated) and JSON.

<versionReports>
    <versionReport>
        <versionsReportFilePath>released-report.txt</versionsReportFilePath>
        <versionsReportFormat>FLAT</versionsReportFormat>
        <releasedModulesOnly>true</releasedModulesOnly>
    </versionReport>
    <versionReport>
        <versionsReportFilePath>version-report.json</versionsReportFilePath>
        <versionsReportFormat>JSON</versionsReportFormat>
        <releasedModulesOnly>false</releasedModulesOnly>
    </versionReport>
</versionReports>

Excluding certain files changes from triggering the release

Certain file changes could be excluded from the release triggering process.

mvn releaser:release -D"ignorePaths=file1.txt,/file2.txt"

Or through the plugin configuration section:

<configuration>
    <ignorePaths>
        <ignoredPath>file1.txt</ignoredPath>
        <ignoredPath>/file2.txt</ignoredPath>
    </ignorePaths>
</configuration>

Include only certain files changes for release triggering

The primary purpose is to trigger creating new releases only if certain changes occur in the repository. If not set, any change triggers the release logic. For example, a library repository with ProtoBuf messages would trigger release only if any of the *.proto files has been modified. This setting disables ignorePaths.

Path matching supports only absolute paths (which start with a /) and suffix path matching. For example, /file.txt will match only file.txt that resides in the repository's root. file.txt will match all files whose path ends with file.txt - /file.txt, /module/file.txt, etc. No wildcards or regexp allowed.

mvn releaser:release -D"requiredPaths=file1.txt,/file2.txt"

Or through the plugin configuration section:

<configuration>
    <reauiredPaths>
        <requiredPath>file1.txt</requiredPath>
        <requiredPath>/file2.txt</requiredPath>
    </reauiredPaths>
</configuration>