As you might or might not know I have been using Apache Maven for quite a few years now and I have come to do all my development projects the maven way although I am probably not a full Maven maven. I am setting up a new development machine at home after being forced to look for a new job so I might as well write down what I do, since it is probably a bit different from the normal install.
For starters I am using Ubuntu Linux and I could just install Maven from the repository like this
sudo aptitude install maven2
and be done with it. I actually do that as a first step. However this does not play nice with having the latest and greatest version of Maven and getting the benefit of the numerous new features and bug fixes from new releases. I could use the Debian Testing repository and use apt pinning to stick with the version there, but things get hairy quickly that way. I also found I don’t have enough patience to wait for the package when a new release comes out, so I get the latest release from the
Apache site and stick it into /opt/apache-maven-2.2.0, add a symlink /opt/maven
sudo ln -s /home/java/software/apache-maven-2.2.0/ maven and add M2_HOME and a M2_HOME/bin to the PATH in my ~/.bashrc.
With this install I get the latest Maven release together with the command completion from the Debian package. So I can type mvn and then use tab and get a list of options and lifecycle goals as well as use tab for command completion(see /etc/bash_completion.d/maven2 for details). Pretty sweet. As a lazy programmer I go one step further and add a bunch of aliases to my ~/.bashrc for often used commands.
alias mci='mvn clean install'
alias mcc='mvn clean compile'
alias mct='mvn clean test'
alias mi='mvn install'
alias mc='mvn compile'
alias mct='mvn test'
alias mcis='mvn clean install -Dmaven.test.skip=true'
alias mis='mvn install -Dmaven.test.skip=true'
alias mej='mvn exec:java'
Depending on projects I work with I also add specific aliases using profiles that need to used and more to additional aliases.
As the last but not least important job I install Sonatype Nexus as my local repository server. The instructions for the install in the Nexus book are all you need. I install Nexus on my developer machine for the following reasons:
So there you have it. Thats all the steps I go through to install Maven and then I bathe in luxury ;-)