Artis IT

Maven and MyEclipse - Build Smoother Java Projects Print E-mail
Written by David Webb   
Monday, 26 November 2007

Overview

I first heard of Maven in a rather unusual way. A guy I didn’t even know overheard a conversation I was having and was interested to find out I was a Java developer. Forty five minutes later, we had shared many views on J2EE, and my takeaway was that I told this guy I would look at Maven. The idea of getting antiquated and / or unidentifiable JAR files out of our source code repository was a real attractive proposition. Additionally, knowing that our development team would be building with the same version of those dependencies was a blessing [wearing my manager’s hat]. At Artis IT, we put Maven to the test … and Maven passed!

Getting started

Getting started with Maven is very simple; just download Maven from the great people at ASF. Maven is located at http://maven.apache.org. Once you install Maven, add the MAVEN_HOME/bin directory to your path and run ‘mvn’ to make sure you are all set.

While Maven works great from the command line, it also integrates nicely with Eclipse (and MyEclipse). The Eclipse plug-in for Maven is located at http://m2eclipse.codehaus.org. Follow the instructions to get the plug-in installed through the Eclipse Software Updates and restart Eclipse.

Mavenify your project

Open Eclipse and go to your workspace. When you right click on a project, you will have a "Maven" menu where you can easily add Maven capabilities to your project, and then search for and add dependencies to your project. The great thing about the dependencies is that the JAR isn’t added to the project. The reference to the JAR is added to the project. This enables all of the developers to consistently build projects with the same JARs. This brings us to the root of Maven, the POM (Project Object Model). The pom.xml file is the command center of the Maven build process. The pom.xml controls dependencies, documentation generation, nested project relationships, custom build instructions, and many more features. The complete POM reference is at http://maven.apache.org/pom.html.

MyEclipse

One of the other popular Eclipse plug-ins is MyEclipse. This subscription based plug-in offers a wide variety of features that simplify all facets of a J2EE project. One of the key features of MyEclipse is the idea of natures. For instance, a project which outputs a WAR would have a web nature. Since MyEclipse hijacks the build process in Eclipse to apply its many natures, and Maven hijacks the build process in Eclipse to override the Eclipse build path with the Maven build dependency hierarchy, there are conflicts. You can add the MyEclipse nature back into the build process by adding the maven-eclipse-plug-in to the section of the pom.xml. Here is an example to add the web nature to a Maven project:

 


maven-eclipse-plugin
2.3



com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder


org.eclipse.jdt.core.javabuilder


com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator


com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator


org.eclipse.wst.validation.validationbuilder




com.genuitec.eclipse.j2eedt.core.webnature


org.eclipse.jdt.core.javanature



 

Summary

Hopefully this offers some insight into Maven and MyEclipse and how they can help you create a smoother build process for your development team and deployment process. Choosing a build methodology is a very important decision and has many different input variables. Artis IT, located in Jacksonville, FL, may be able to help. Our team of expert J2EE architects can perform the due diligence required to figure out the best solution for your Java development team and/or organization. You can contact Artis IT (www.artisit.com) at 904-861-2366 for more information on how we can smooth out your Java development process, build process or project lifecycle. Technically speaking, we know IT!

 

Last Updated ( Friday, 07 March 2008 )
 
< Prev   Next >