Version 11

    Introduction

     

    Maven projects often contain a version string in multiple places: the pom of each module, and sometimes properties files and/or java files.  This page describes some tools to make it easier to update the version of a Maven project.  This might be used when branching or releasing a project.  If the project is using the standard maven release plugin, the techniques listed on this page are not necessary.

     

    Using Perl to Update Versions

    One line unix/linux command

     

    perl -pi -e 's/1.2.0-SNAPSHOT/1.2.0.GA/g' `find . -name \*.xml -or -name \*.java`
    

     

    More information about using this command can be found in David's Maven Release Process

     

    Platform Independent Script

    A Perl script called "find_replace.pl" is a general find and replace tool, and can be used for updating project version strings located in the pom.xml and/or other text files.  It is available in svn.

    http://anonsvn.jboss.org/repos/maven/tools/perl/

     

    Basic usage information can be seen by running the script with no parameters.

     

    perl find-replace.pl
    

     

    This script can be used to update your project poms, java files, and properties files.

     

    perl find-replace.pl -e -w "(pom.xml|\.java)" -x "(target|output)" 1.0.0-SNAPSHOT 1.0.0.GA

     

    This will find all files named "pom.xml" or ending with ".java" except those located in the target or output subdirectories.  If you leave off the "-e" parameter the script will run in read-only mode and will only provide a preview of the changes.

     

    Using the Maven Versions Plugin

     

    The Maven Versions Plugin (update-child-modules goal) can be used to update the parent references in module poms.

    1. Update the version in the root pom.
    2. Run: mvn versions:update-child-modules