-
Notifications
You must be signed in to change notification settings - Fork 243
/
introduction-to-archetypes.apt
102 lines (84 loc) · 5.39 KB
/
introduction-to-archetypes.apt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
------
Introduction to Archetypes
------
Jason van Zyl
------
2009-08-26
------
~~ Licensed to the Apache Software Foundation (ASF) under one
~~ or more contributor license agreements. See the NOTICE file
~~ distributed with this work for additional information
~~ regarding copyright ownership. The ASF licenses this file
~~ to you under the Apache License, Version 2.0 (the
~~ "License"); you may not use this file except in compliance
~~ with the License. You may obtain a copy of the License at
~~
~~ http://www.apache.org/licenses/LICENSE-2.0
~~
~~ Unless required by applicable law or agreed to in writing,
~~ software distributed under the License is distributed on an
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~~ KIND, either express or implied. See the License for the
~~ specific language governing permissions and limitations
~~ under the License.
~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/doxia/references/apt-format.html
Introduction to Archetypes
What is Archetype?
In short, Archetype is a Maven project templating toolkit. An archetype is defined as <an original pattern or model
from which all other things of the same kind are made>. The name fits as we are trying to provide a system that
provides a consistent means of generating Maven projects. Archetype will help authors create
Maven project templates for users, and provides users with the means to generate parameterized versions
of those project templates.
Using archetypes provides a great way to enable developers work quickly in a way consistent with best practices employed
by your project or organization. Within the Maven project, we use archetypes to try and get our users up and running
as quickly as possible by providing a sample project that demonstrates many of the features of Maven, while introducing
new users to the best practices employed by Maven. In a matter of seconds, a new user can have a working Maven project
to use as a jumping board for investigating more of the features in Maven. We have also tried to make the Archetype
mechanism additive, and by that we mean allowing portions of a project to be captured in an archetype so that pieces
or aspects of a project can be added to existing projects. A good example of this is the Maven site archetype.
If, for example, you have used the quick start archetype to generate a working project, you can then quickly
create a site for that project by using the site archetype within that existing project. You can do anything like
this with archetypes.
You may want to standardize J2EE development within your organization, so you may want to provide archetypes
for EJBs, or WARs, or for your web services. Once these archetypes are created and deployed in your organization's
repository, they are available for use by all developers within your organization.
* Using an Archetype
To create a new project based on an Archetype, you need to call <<<mvn archetype:generate>>> goal, like the following:
-----
mvn archetype:generate
-----
Please refer to {{{/archetype/maven-archetype-plugin/}Archetype Plugin page}}.
* Provided Archetypes
Maven provides several Archetype artifacts:
*-----------------------------+----------------+
|| Archetype ArtifactIds || Description ||
*-----------------------------+----------------+
| maven-archetype-archetype | An archetype to generate a sample archetype project. |
*-----------------------------+----------------+
| maven-archetype-j2ee-simple | An archetype to generate a simplifed sample J2EE application. |
*-----------------------------+----------------+
| maven-archetype-mojo | An archetype to generate a sample a sample Maven plugin. |
*-----------------------------+----------------+
| maven-archetype-plugin | An archetype to generate a sample Maven plugin. |
*-----------------------------+----------------+
| maven-archetype-plugin-site | An archetype to generate a sample Maven plugin site. |
*-----------------------------+----------------+
| maven-archetype-portlet | An archetype to generate a sample JSR-268 Portlet. |
*-----------------------------+----------------+
| maven-archetype-quickstart | An archetype to generate a sample Maven project. |
*-----------------------------+----------------+
| maven-archetype-simple | An archetype to generate a simple Maven project. |
*-----------------------------+----------------+
| maven-archetype-site | An archetype to generate a sample Maven site which demonstrates some of the supported document types like APT, XDoc, and FML and demonstrates how to i18n your site. |
*-----------------------------+----------------+
| maven-archetype-site-simple | An archetype to generate a sample Maven site. |
*-----------------------------+----------------+
| maven-archetype-webapp | An archetype to generate a sample Maven Webapp project. |
*-----------------------------+----------------+
For more information on these archetypes, please refer to the {{{/archetypes/index.html}Maven Archetype Bundles page}}.
* What makes up an Archetype?
Archetypes are packaged up in a JAR and they consist of the archetype metadata which describes the contents of
archetype, and a set of {{{http://velocity.apache.org/}Velocity}} templates which make up the prototype
project. If you would like to know how to make your own archetypes, please refer to our
{{{../mini/guide-creating-archetypes.html}Guide to creating archetypes}}.