I have created and installed my own archetype and now I am trying to create a new project with it with the command line. When I run
mvn archetype:generate -DarchetypeCatalog=local
I can see that the archetype is installed:
19: local -> myOwnArchetype (Archetype - my own archetype)
And in the archetype-catalog.xml I find
<archetype>
<groupId>de.rm.trial</groupId>
<artifactId>myOwnArchetype</artifactId>
<version>1.0</version>
<description>Archetype - my own archetype</description>
</archetype>
When I try
mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=de.rm.trial -DartifactId=myOwnArchetype -DarchetypeVersion=1.0 -DgroupId=de.rm.trial.mynew -DartifactId=myNewProject
it still asking "Choose number:".
I found this link Specify archetype for archetype:generate on command line so I tried it with
mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=de.rm.trial -DartifactId=myOwnArchetype -DarchetypeVersion=1.0 -DgroupId=de.rm.trial.mynew -DartifactId=myNewProject -DinteractiveMode=false
Unfortunately maven tells
[INFO] No archetype defined. Using maven-archetype-quickstart (de.rm.trial:maven-archetype-quickstart:1.0)
I have no more idea, what might be wrong with it?
For doing so, you need to install the archetype by using the following command: After that, you will be able to use your new archetype while creating a new Maven project with the mvn archetype:generate command.
The maven-archetype-plugin allows the user to create a Maven project through the generate goal and existing archetype. For more information on this plugin, you can visit the homepage.
How to Create an Archetype An archetype is a normal Maven project with the following extra content: To create an archetype manually, we can start with a newly created Maven project and then we can add the resources mentioned above.
It's an XML file named archetype-metadata.xml and located in the META-INF/maven directory of the jar. It's used to describe archetypes' metadata: The requiredProperties tag is used for providing properties during project generation. Thus, we'll be prompted to provide values for them, with the choice to accept the default value.
You have used artifactId
instead of archetypeArtifactId
. Try the following:
mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=de.rm.trial -DarchetypeArtifactId=myOwnArchetype -DarchetypeVersion=1.0 -DgroupId=de.rm.trial.mynew -DartifactId=myNewProject -DinteractiveMode=false
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