Sunday, August 12, 2012

Maven + Eclipse = Amazing!

On last weekend, I am starting to use Maven for my home development. Before this it was very clumsy, every time when I building the project, it is very annoying that the compiler could not find the appropriate jar dependencies on this particular jar. By using Maven, the compiler no longer complaining on jar dependencies, rather it manage the dependencies for me.

When I first setting up Maven, I use to write XML code. To be frank, I don't really like this work because it took me a lot of effort to figure out the coordinate. To me, this is so much annoying. I don't care, just give me the latest version will do.

Thus I pass this job to Eclipse. BTW, I am just Linux version of Juno Eclipse in Fedora 17, there might be some different with previous version because I found out that the plugins tab in my Eclipse was missing, not really sure does it happen to previous version as well. My previous experience with Maven is editing the POM file without going through the UI, please forgive me on the laziness to find out the truth.

Lets move on. When open up the POM file, there is a dependencies tab. Clink on that there is a Add button in it. Click on that will bring up a dialog just shown as the picture below:

Notice that the top section consist of Group Id field, Artifact Id field, and Version field. Forget about this section unless you really sure what you need on a particular jar. Then the section right below is my favourite, it consist of a search key field and a search result. Just type in anything here, and Eclipse will find it for me. When there is a result, just double click on the entry, Eclipse will handle the coordinate for me.

This is the greatest part of using Maven in Eclipse. Once done editing on the POM file, save it, and Eclipse will trigger the download. This was amazing!!

Anyhow, I still need to update the build path although Eclipse have done the download. Don't get me wrong, I am not require to configure the project build path. I just type this command:

mvn eclipse:eclipse -Dwtpversion=2.0

Go to Eclipse, right click on the project > Maven > Update Project, and then say "I am Done!".

No comments: