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:
- it acts as my local proxy allowing me to pretty much work offline smoothly without needing to use the offline mode in most cases.
- I can clean out my ~/.m2/repository folder for debugging or other issues (IDE slowdown..) and getting things back afterwards is MUCH faster
- I can use it to install thirdparty jars more permanently (e.g. the android jar or oracle jdbc driver jar) in a clean manner without polluting my ~/.m2/repository or depending on an external private repo server
- I can test the release plugin usage against my local proxy server
So there you have it. Thats all the steps I go through to install Maven and then I bathe in luxury ;-)
Dieser Beitrag hat 4 Kommentare
Thanks for the post Manfred – of course, thanks to you I already have most of this in place, but there’s some great stuff here to increase dev productivity in general.
Pingback: How to mavenize a typical web application build: JasperServer 3.7 sample webapp | simpligility
Pingback: Improving the mavenized JasperServer 3.7 sample webapp build | simpligility
Pingback: Sonatype Maven Training – MVN 201 continued | simpligility
Kommentare sind geschlossen.