Maven Project Templates - Maven

What are project templates?

Maven includes different types of project templates (614 in numbers) with the cocept of Archetype. Maven helps users to quickly start a new java project using following command

What is Archetype?

Archetype is a Maven plugin used to create a project structure as per its template. Let’s use quickstart archetype plugin to create a simple java application in this chapter.

Using Project Template

Now open command console, go the C:\ > MVN directory and execute the following mvn command
Then Maven will start executing will ask to choose required archetype
Now press Enter to choose to default option(7: maven-archetype-quickstart). Then Maven will ask for project detail. Then enter the project detail and press Enter if default value is provided. You can also ignore it by entering your own value.
Now Maven will ask for project detail confirmation then press enter or press Y.
Now Maven will start creating project structure and will display the following:

Created Project

Now go to C:\ > MVN directory. Find a java application project created named health which was given as artifactId at the time of project creation. Then Maven will create a standard directory layout for the project as shown below:
template_project_structure

Created POM.xml

Maven generates a POM.xml file for the project as listed below:

Created App.java

Let’s create a sample java source file, App.java for the project as listed below:
Location: C:\ > MVN > health > src > main > java > com > companyname > insurance > App.java

Created AppTest.java

Now Maven creates a sample java source test file, AppTest.java for the project as listed below:
Location: C:\ > MVN > health > src > test > java > com > companyname > insurance > AppTest.java
Let’s see the magic of Maven. You can create any kind of project using single command in maven and can kick-start your development.

Different Archetypes

Sr.No. Archetype ArtifactIds & Description
1

maven-archetype-archetype

An archetype, which contains a sample archetype.

2

maven-archetype-j2ee-simple

An archetype, which contains a simplified sample J2EE application.

3

maven-archetype-mojo

An archetype, which contains a sample a sample Maven plugin.

4

maven-archetype-plugin

An archetype, which contains a sample Maven plugin.

5

maven-archetype-plugin-site

An archetype, which contains a sample Maven plugin site.

6

maven-archetype-portlet

An archetype, which contains a sample JSR-268 Portlet.

7

maven-archetype-quickstart

An archetype, which contains a sample Maven project.

8

maven-archetype-simple

An archetype, which contains a simple Maven project.

9

maven-archetype-site

An archetype, which contains a sample Maven site to demonstrates some of the supported document types like APT, XDoc, and FML and demonstrates how to i18n your site.

10

maven-archetype-site-simple

An archetype, which contains a sample Maven site.

11

maven-archetype-webapp

An archetype, which contains a sample Maven Webapp project.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Maven Topics