Pages

Thursday, 24 July 2014

What is archetype or How can you create a maven project ?


 mvn archetype:generate -DgroupId=org.sonatype.mavenbook \
-DartifactId=simple \
-Dpackage=org.sonatype.mavenbook \
-Dversion=1.0-SNAPSHOT

An archetype is defined as “an original model or type after which other similar things are patterned; a prototype.” A number of archetypes are available in Maven for anything from a simple application to a complex web application, and the archetype:generate offers a list of archetypes to choose from. The plugin is the prefix archetype, and the goal is generate.

The Maven Archetype plugin creates a directory simple/ that matches the artifactId. This is every Maven project has what is known as a Project Object Model (POM) in a file named pom.xml. This file describes the project, configures plugins, and declares dependencies. Our project’s source code and resources are placed under src/main. In the case of our simple Java project this will consist of a few Java classes and some properties file. In another project, this

could be the document root of a web application or configuration files for an application server.
src/main/java and classpath resources are placed in
In a Java project, Java classes are placed in
src/main/resources.
TestNG tests are placed in src/test/java, and classpath resources for tests are located in src/test/re-

Our project’s test cases are located in src/test. Under this directory, Java classes such as JUnit or
sources.

No comments:

Post a Comment