Thursday, August 16, 2007

Using Maven1(maven) and Maven2(mvn) at the same time

I am working on a project where I need to use maven and mvn at the same time. I got tired of switching my maven_home variable, so I came up with a solution that allows me to switch transparently.

Note: This is tested on OSX, and will likely work on any linux or unix OS. Not sure if it will work under cygwin or not. its a definite maybe.

1. remove references to maven from your path variable.
2. in your .profile create env variables for both maven and mvn home directories. Mine are called M1_HOME and M2_HOME.
3. edit your .bashprofile or and create functions like so:
function maven
{
export MAVEN_HOME=$M1_HOME
$MAVEN_HOME/bin/maven $@
}

function mvn
{
export MAVEN_HOME=$M2_HOME
$MAVEN_HOME/bin/mvn $@
}


Thats it!

-sean

No comments: