Dec
29
Filed Under (Builds) by Aneesha on 29-12-2007

I’ve spent the last couple of days getting re-acquainted with the likes of Java mainly to prevent a total shock to the system when I start my new job in a few days. I’m coming back to Java after a 6 month programming day job break - I still played around with Java but spent evenings mostly working with either Python (for Machine Learning) or Ruby on Rails (for web stuff). Admittedly coming back to a compiled language is quite a shock to the system. I thought I’d look at Maven as an alternate to just getting Eclipse to compile and package projects for me (partly inspired by The F5 Key Is Not a Build Process blog post from Coding Horror).

So far I am impressed:

  • Compile a project
    mvn compile
  • Package my web app
    mvn package
  • Run unit tests
    mvn test
  • Skip tests but package anyway
    mvn package -Dmaven.test.skip=true

… and then I was just about to set up Eclipse to handle the dependencies myself when I discovered the Maven Eclipse plugin. The Maven Eclipse plugin generates the .classpath and .project files from the pom.xml file.

  1. Close Eclipse, if you have it running.
  2. Tell Eclipse where your Maven 2 repository resides:mvn eclipse:add-maven-repo -Declipse.workspace=”Insert path to your workspace”

    Note: This actually sets the org.eclipse.jdt.core.classpathVariables.M2_REPO variable in the Eclipse prefs file.

  3. Change to your project directory (in your workspace). Generate the Eclipse project files:mvn eclipse:eclipse

In conclusion my initial dealings with Maven 2 have been quite pleasant so I think I will be sticking with it for a while.

    Read More   

Comments

Shannon on 29 December, 2007 at 1:12 pm #

Maven is always great when you start out with simple projects…. but if you try to do anything different it can lead to frustration. That being said whenever I go back to doing something in ant these days it feels so verbose and clunky.

This aslo makes interesting reading: http://fishbowl.pastiche.org/2007/12/20/maven_broken_by_design


Aneesha on 30 December, 2007 at 12:32 am #

Thanks Shannon. I will be giving Ant a go as well. I guess coming from Ruby land, Maven seems more familiar, given that I’ve been using things like RubyGems and Rake.

Running mvn install took at least 15 minutes and I ran into plugin not found in repository issues for the very first app I tried to package!!!! I had to add an alternate snapshot repository. So I guess I will be backing up my local M2 repository…

Theres also Raven (http://raven.rubyforge.org/) which I’ve heard is meant to be RubyGems and Rake for Java builds.


Post a Comment
Name:
Email:
Website:
Comments: