Archiwum kategorii: Maven

Build and Release with Maven

 

While releasing  application to UAT or Production environment, following actions/goals should be performed.

  • Commit all changes to SVN trunk repository
  • Change pom version from SNAPSHOT to actual release version. For example if current development version is 1.0-SNAPSHOT, then make it to 1.0 release version
  • Tag this release in SVN repository
  • Increment the development version in trunk.

All above steps can be performed using Maven release command.

mvn release:clean release:prepare -DscmCommentPrefix=”DESC”

Where,

  • scmCommentPrefix is the prefix for SVN commit comment. Normally this would JIRA ID.

Optionally you can insert below properties.

  • -DdevelopmentVersion is the current development SNAPSHOT version
  • -DreleaseVersion is the actual release version, which is normally without SNAPSHOT string

The command will

  • Check for any local outstanding changes – and if any are found, it will fail. Note that any tests which do not clean up properly may cause issues here and you may need to manually delete such files.
  • update the local POMs to new (release/non-SNAPSHOT) versions
  • compile and run the tests
  • commit the updated POMs (with the release versions) to the release branch
  • generate a new tag from SVN from the release branch
  • update the local POMS to new development SNAPSHOT versions
  • Commit new POMs to the release branch (with development SNAPSHOT versions).

 

maven sertting.xml example file

<settings xmlns=”http://maven.apache.org/SETTINGS/1.0.0″
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd”>

<servers>
<server>
<id>robocomp.eu.svn</id>
<username> XXXXXX</username>
<password>XXXXXXX</password>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
</servers>

<profiles>
<profile>
<repositories>
<repository>
<id>mvnrepository</id>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>

<repository>
<id>robocomp.eu.svn</id>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://svn.robocomp.eu/svn/repo1/</url>
</repository>

</repositories>
</profile>
</profiles>

</settings>

 

 

Connecting to svn from Java app – pom file

<!– ============================================================= –>
<!– Source control system –>
<!– ============================================================= –>
<scm>
<connection>scm:svn:http://svn.robocomp.eu/svn/repo1/Smarthouse/trunk</connection>
<developerConnection>scm:svn:http://svn.robocomp.eu/svn/repo1/Smarthouse/trunk</developerConnection>
</scm>