I am new to Maven and am using the maven.apache.org tutorial here as an introduction.
In the "How do I make my first Maven project?" section of the tutorial, it teaches us to generate a Maven archetype project by executing the following command:
mvn archetype:generate
After Maven downloaded many artifacts, it suddenly stopped and asked the following question on the command line:
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 149:
The Apache tutorial does not describe this prompt.
I have two questions:
1. What is the question above asking for? How should it be answered such that the mvn archetype:generate
process continues?
2. Conventionally, do people use mvn archetype:generate
to create a Maven project?
--------------Update---------------------
With respect to my 1st question, I pressed "enter" without inputting any value and got the following output:
Choose version: 1: 1.0-alpha-1 2: 1.0-alpha-2 3: 1.0-alpha-3 4: 1.0-alpha-4 5: 1.0 6: 1.1 Choose a number: 6:
What is that?
I input "1" in above case, then I got the following things:
Define value for property 'package': : : Define value for property 'groupId': : Define value for property 'artifactId': : ...
How can I define them?
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.
All you need to specify is a groupId , artifactId and version . These three parameters will be needed later for invoking the archetype via archetype:generate from the commandline.
After entering these information, Maven will show you all the information you entered and ask you to verify project creation. If you press Y and then enter, voila your project is created with the artifact and settings you chose. You can also read maven-archetype-plugin's usage site.
The Archetype Plugin allows the user to create a Maven project from an existing template called an archetype. It also allows the user to create an archetype from an existing project.
mvn archetype:generate
command is used to create a project from an existing template. There are several archetype's defined by many developers and project groups. When you run the command, maven does following things:
After entering these information, Maven will show you all the information you entered and ask you to verify project creation. If you press Y and then enter, voila your project is created with the artifact and settings you chose.
You can also read maven-archetype-plugin's usage site.
It is asking you which archetype you want to use to seed your project. If you press "enter" at that prompt, it'll give you a list of available choices. You can use maven-archetype-quickstart
to just create a simple project (it may prompt you to pick a repository after this, in that case, just enter the number that corresponds to the first repository listed after you enter this).
To answer your other question: yes, using an archetype is a common way for setting up a new project. Mainly because there are plenty of archetypes out there for all kinds of projects/modules. Once you know which archetype you want, using it to bootstrap a project is the simplest way to get started.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With