Entries in Java (1)

Thursday
Oct212010

Create a Dynamic Web Project in Eclipse using Maven

Maven is a project management tool popular among programmers and project mangers alike. If configured correctly it enables you and your dev team to build (and run) a project regardless of the IDE that was used to develop it. It does this by automatically pulling in the required dependencies (that is, after they were set up correctly in the pom.xml). 

Maven can also be used the other way around, however, for it's easy to generate an Eclipse project from a Maven project using:

mvn eclipse:eclipse

This command generates a general Java project with the required dependencies (JARs) in the project's classpath.

Dynamic Web Project

You will notice that if the project is actually a Dynamic Web Project (WTP), e.g. a JSP or webservice project, it may not be as convenient to get it configured correctly in Eclipse (like setting up a debug Tomcat configuration). To facilitate this, Maven provides the following:

mvn eclipse:eclipse -Dwtpversion=1.5

Upon completion you'll be able to import the project into Eclipse.

Note: If you're mucking around and you'd like to erase the generated Eclipse project config, you can run this command:

mvn eclipse:clean

 

Have fun!