icon-arrow icon-check icon-mail icon-phone icon-facebook icon-linkedin icon-youtube icon-twitter icon-cheveron icon-download icon-instagram play close close icon-arrow-uturn icon-calendar icon-clock icon-search icon-chevron-process icon-skills icon-knowledge icon-kite icon-education icon-languages icon-tools icon-experience icon-coffee-cup
Werken bij Integration & Application Talents
Blog 17/03/2014

Using the Maven Release plugin with Mercurial SCM

Mercury

Whitehorses
Mike Heeren /
Integratie expert

The Maven Release plugin can be used to release a project using Maven. Normally, a release can be made in two simple steps: prepare en perform. When the Mercurial SCM (Source Code Management) is used, this process requires a little more configuration. I performed the described steps using Hg (Mercurial) version 2.0.2 and maven-release-plugin version 2.4.2 on a Ubuntu 12.04 VM. The used distribution servers are Nexus 2.2-01 instances.

It’s important that all servers described in your pom.xml file, in my case a snapshot and a release server, are also configured in your Maven settings.xml file. Open your settings.xml file.

sudo gedit $MAVEN_HOME/settings.xml

The servers must be configured here. The ID should be identical to the ID used to describe the server in the pom.xml file. The username and password should represent a user which is allowed to create new distributions on the server.

<servers>
    <server>
        <id>snapshot_repository_id</id>
        <username>snapshot_repository_username</username>
        <password>snapshot_repository_password</password>
    </server>
    <server>
        <id>release_repository_id</id>
        <username>release_repository_username</username>
        <password>release_repository_password</password>
    </server>
</servers>

The next step is the prepare statement. Normally, this statement can be executed by the following command. The –e flag is used to print the error stack trace in case the execution fails. Before you execute this statement, it’s important that all local modifications have been pushed to Mercurial.

mvn release:prepare –e

Where I executed this statement, the stack trace contained the following lines. For some reason, the authentication for the Mercurial isn’t set and you will not be prompted to enter a username and password.

[ERROR] 
EXECUTION FAILED
Execution of cmd : push failed with exit code: 255.
Working directory was: 
<My working directory>

Your Hg installation seems to be valid and complete.
Hg version: 2.0.2 (OK)

A workaround for this error that worked for me, was to split the actual prepare statement and the Mercurial push statements. To split these statements, a flag can be added to the prepare statement:

mvn release:prepare –e –DpushChanges=false

If this statement is executed successfully, you can manually push the changes to the Mercurial server using the following statement:

hg push

The final step of the Maven Release plugin is the perform step. Usually this can be done by executing the following statement. Again, the –e flag is toggled to display the stack traces of possible errors.

mvn release:perform –e

This statement also uses Hg operation, so probably this statement will fail too. However, it’s possible to set a username and password using flags. To do this, use the following statement.

mvn release:perform –e –Dusername=<SCM username> -Dpassword =<SCM password>

After this statement was executed successfully, the application was deployed and distributed successfully to the Nexus snapshot and Nexus release repositories.

References:

http://maven.apache.org/maven-release/maven-release-plugin/

http://stackoverflow.com/questions/11769537/mercurial-maven-release-plugin-problems

http://maven.apache.org/maven-release/maven-release-plugin/perform-mojo.html

Overzicht blogs

Geen reacties

Geef jouw mening

Reactie plaatsen

Reactie toevoegen

Jouw e-mailadres wordt niet openbaar gemaakt.

Geen HTML

  • Geen HTML toegestaan.
  • Regels en alinea's worden automatisch gesplitst.
  • Web- en e-mailadressen worden automatisch naar links omgezet.
Whitehorses
Mike Heeren /
Integratie expert

Wil je deel uitmaken van een groep gedreven en ambitieuze experts? Stuur ons jouw cv!