The Maven release plugin

Releasing a project requires a lot of repetitive tasks. The objective of the Maven release plugin is to automate them. The release plugin defines the following eight goals, which are executed in two stages, preparing the release and performing the release:

  • release:clean: This goal cleans up after a release preparation
  • release:prepare: This goal prepares for a release in Software Configuration Management (SCM)
  • release:prepare-with-pom: This goal prepares for a release in SCM and generates release POMs by fully resolving the dependencies
  • release:rollback: This goal rolls back to a previous release
  • release:perform: This goal performs a release from SCM
  • release:stage: This goal performs a release from SCM into a staging folder/repository
  • release:branch: This goal creates a branch of the current project with all versions updated
  • release:update-versions: This goal updates versions in the POM(s)

The preparation stage will complete the following tasks with the release:prepare goal:

  • Verify that all the changes in the source code are committed.
  • Make sure that there are no SNAPSHOT dependencies. During the project development phase, we use SNAPSHOT dependencies but at the time of the release, all dependencies should be changed to a released version.
  • Change the version of project POM files from SNAPSHOT to a concrete version number.
  • Change the SCM information in the project POM to include the final destination of the tag.
  • Execute all the tests against the modified POM files.
  • Commit the modified POM files to the SCM and tag the code with the version name.
  • Change the version of POM files in the trunk to a SNAPSHOT version and then commit the modified POM files to the trunk.

Finally, the release will be performed with the release:perform goal. This will check the code from the release tag in the SCM and run a set of predefined goals: site, deploy-site.

The maven-release-plugin is not defined in the super POM and should be explicitly defined in your project POM file. The releaseProfiles configuration element defines the profiles to be released and the goals configuration element defines the plugin goals to be executed during the release:perform goal. In the following configuration, the deploy goal of the maven-deploy-plugin and the single goal of the maven-assembly-plugin will get executed:

<plugin>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.5</version>
  <configuration>
    <releaseProfiles>release</releaseProfiles>
    <goals>deploy assembly:single</goals>
  </configuration>
</plugin>

Note

More details about the Maven release plugin are available at http://maven.apache.org/maven-release/maven-release-plugin/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.197.136