Alex's Personal Blog

News and updates for friends and family

Articles tagged with eclipse

Trouble with Maven

Posted: Tue, 11 Mar 2008 by

I've tried to use Maven during my Java development but have found it rather frustrating for a few reasons.

The documentation is a bit sparse - Most of what you need is represented but setting up your own settings, deploying artifacts a repository and other more advanced subjects are under represented. Deploying artifacts is painful - This mostly goes along with the first point. The syntax, once figured out is far from obvious and much to verbose for my taste. That's one of the drawbacks of extreme flexibility... extreme complexity.

Because I tend to be a perfectionist when it comes to code I write at home I had taken a break from coding Java for a while (except at work of course).

Recently I've had some really good ideas pop into my head as well as how to implement those ideas so I wanted to get started again with Maven. I was able to utilize the the Q4E project which is a Maven plugin for Eclipse which I've found more stable and consistent than the original M2Eclipse plugin (though I haven't tried it in a while so it may have improved). This combined with my already POM-enabled projects in source control made for a pretty easy return to Java development. Unfortunately there was some frustration just around the corner.

When my new application was getting bulky enough to start needing some logging I decided to start using log4j which is commonly used in Java development. All I needed to do was add it to my project's POM as a dependency and Maven should have taken care of downloading it and adding it to my CLASSPATH but unfortunately that wasn't the case. Maven wasn't able to figure out how to get 3 of log4j's dependencies. Usually in a case like this it gives good suggestions on where to download them. Unfortunately the links that were given kept redirecting me somewhere on the Java site that wasn't what I was after. After struggling with the issue for a few hours I gave up and started using the Java SDK's (inferior, IMHO) logging mechanism but not being able to use log4j continued to nag at me.

This morning I decided to give it another try and this time the first thing I did was a google search which brought me to this blog entry. While installing a separate piece of software, Artifactory for a Maven Repository Proxy, this was something I had done using Proximity in the past so I was pretty familiar with what to expect. As I already had a server machine setup and ready to run Tomcat I was able to install Artifactory pretty quickly. Once installed I followed the instructions in the blog post and in the Artifactory documentation for setting up Maven to look at the repository proxy first and 2 of the 3 missing dependencies were downloaded no problem. I had to do an explicit search for jms-1.1.jar to get the last dependency but I followed similar instructions for installing it into my new repository. Long story short I'm now able to use log4j in my Java coding. I can also easily deploy the artifacts I create to my own repository with ease.

Now I need to stop messing around with all this stuff and continue my coding.

Updated: 2012-02-25 17:32:35 -0800