Monday, June 11, 2012

one-line update for all pom versions in multi-module project

We have a multi-module Maven project with many children, so it's a little annoying to bump the version number. Here's a one-liner to do it, just replace _OLD_ and _NEW_ with the old version and new version, respectively.
for f in `find . -name pom.xml`; do sed 's/_OLD_/_NEW_/' $f > $f.new; mv $f.new $f; done
for example:
for f in `find . -name pom.xml`; do sed 's/1.1.23-SNAPSHOT/1.1.24-SNAPSHOT/' $f > $f.new; mv $f.new $f; done

*DON'T FORGET TO CHECK THE DIFF (you ARE using Git, right?)*

** Update (thanks jamcole)**

Or even easier, use the Maven versions plugin (from the top-level project):
mvn versions:set

No comments: