Wednesday, April 18, 2012

Usage of Maven J2EE archetype instead of using Eclipse dynamic web project.

Eclipse Dynamic Web project is not suitable for a maven based project to locate jsp, java, properties and test sources.
If you use that, you will start to configure complicated configuration build path, war destination target, test source location and packaging issues so on. I strongly recommend you to use maven archetype that follows maven directory convention.

It's appeared that "maven-archetype-webapp" archetype is little outdated to use for latest project.
The best way so far is, use codehaus webapp archetype.

For JDK5 based project
mvn archetype:generate -DgroupId=<your group> -DartifactId=<your artifact> -DarchetypeArtifactId=webapp-jee5 -DarchetypeVersion=1.3 -DarchetypeGroupId=org.codehaus.mojo.archetypes

For JDK6 based project
mvn archetype:generate -DgroupId=<your group> -DartifactId=<your artifact> -DarchetypeArtifactId=webapp-javaee6 -DarchetypeGroupId=org.codehaus.mojo.archetypes


I tried to generate without "-DarchetypeGroupId=org.codehaus.mojo.archetypes" option. then it will show error message.
"The desired archetype does not exist (org.apache.maven.archetypes:webapp-jee5-1.3:1.0)". the reason is the "org.codehaus.mojo.archetypes" archetype group is not maven default archetype group id. For more detail, please refer below link
http://docs.codehaus.org/display/MAVENUSER/Archetypes+List

After that, simply import this project into eclipse




1 comment:

  1. thanks, I've been struggling with the webapp archetype.

    Alan

    ReplyDelete