blob: fc59b6167b268595d2b6b533f1740de38c726224 [file] [log] [blame]
------
Usage
------
Franz Allan Valencia See
------
17 July 2006
------
~~ Copyright 2006 The Apache Software Foundation.
~~
~~ Licensed 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/guides/mini/guide-apt-format.html
Usage
* Create
The create goal creates a pom, the default files (source, test, resources,
test-resources, site-resources), in a specific directory structure. The most
basic way of using this is by calling the goal with only two expressions: the
<<<groupId>>> and <<<artifactId>>> of the project to be build. For example,
using
+-----+
mvn archetype:create \
-DgroupId=sample.group.id \
-DartifactId=sample-artifact-id
+-----+
this would create an <<<App.java>>> and an <<<AppTest.java>>>, both under the
<<<sample.group.id>>> package. The <<<App.java>>> is a simple "Hello World"
program while the <<<AppTest.java>>> is a subclass of
<<<junit.framework.TestCase>>> that has one test which always passes.
You can also specify other parameters such as version of the project to be
created, the <<<packageName>>> of the classes, <<<remoteRepositories>>> and
<<<pomRemoteRepositories>>> (See
{{{examples/remote-repositories.html}Specifying the Remote Repositories}}),
and the <<<archetypeGroupId>>>,
<<<archetypeArtifactId>>>, and <<<archetypeVersion>>>.
If the version is not specified, the default will be used which is
<<<1.0-SNAPSHOT>>>. Also, if the <<<packageName>>> is not specified, the
<<<maven-archetype-plugin>>> would derive the classes default package name
based on the <<<groupId>>> (i.e. a <<<groupId sample.group.id>>> would have a
default package name <<<sample.group.id>>>).
Moreover, if the <<<archetypeGroupId>>>, <<<archetypeArtifactId>>> and
<<<archetypeVersion>>> is not specified (as with the example above), the
default would be used, which is <<<org.apache.maven.archetypes>>>,
<<<maven-archetype-quickstart>>> and <<<1.0-SNAPSHOT>>> respectively.
Thus, the above command is the same as
+-----+
mvn archetype:create
-DgroupId=sample.group.id \
-DartifactId=sample-artifact-id \
-Dversion=1.0-SNAPSHOT \
-DpackageName=sample.group.id \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DarchetypeVersion=1.0-SNAPSHOT
+-----+
But if you want to use a different archetype other than the default, you'd
have to specify the following parameters: <<<archetypeGroupId>>>,
<<<archetypeArtifactId>>>, and <<<archetypeVersion>>>.
So for example, if you wish to create a project with a <<<groupId>>>
<<<my.company.projects>>>, <<<artifactId>>> <<<my-project>>>, using an
archetype with an <<<artifactId>>> <<<my-archetype>>>, <<<version>>>
<<<1.0-archetype-SNAPSHOT>>>, under the <<<groupId>>>
<<<my.company.archetypes>>>, you'd have to execute
+-----+
mvn archetype:create \
-DgroupId=my.company.projects \
-DartifactId=my-project \
-DarchetypeGroupId=my.company.archetypes \
-DarchetypeArtifactId=my-archetype \
-DarchetypeVersion=1.0-archetype-SNAPSHOT
+-----+
But if the archetype that you're going to use has an element
(<<<archetypeGroupId>>>, <<<archetypeArtifactId>>>, or <<<archetypeVersion>>>)
has the same value as that of the default, then you don't have to specify that
element.
For example, if you're going to use <<<maven-archetype-webapp>>>
<<<version>>> <<<1.0-SNAPSHOT>>> which is in under the <<<groupId>>>
<<<org.apache.maven.archetypes>>>, you can simply use the following command
+-----+
mvn archetype:create
-DgroupId=my.company.projects
-DartifactId=another-project
-DarchetypeArtifactId=maven-archetype-webapp
+-----+
* Create From Project
Builds archetype containers based from an existing Maven project (<currently
under development>).