Check the maven guide also if you need some help. Some useful info can be found here .
This example is pretty straightforward. You can start from the first commit and build/run the project to see which output you get; each next commit just add/change something with an explanation of what is going on.
> JDK 1.8+ should be fine :)
> Maven 3+ should work.
e.g. I am using maven-archetype-plugin:3.0.1
- Checkout the code.
mvn clean install
on the rootpom.xml
to getmaven-archetype-sample-1.0-SNAPSHOT.jar
in your.m2
- Once this is done - you can use that archetype to generate your project structure.
mvn archetype:generate \
-DarchetypeGroupId=com.ivk23.maven.archetype.sample \
-DarchetypeArtifactId=maven-archetype-sample \
-DarchetypeVersion=1.0-SNAPSHOT \
-DgroupId=my.app.group.id \
-DartifactId=my-mew-app \
-Dversion=2.0.0-SNAPSHOT \
-DmyProjectName=HelloWorldArchetype \
-DinteractiveMode=false
! To be able to run mvn you have to install and configure Maven, but that's another story.
- Because the archetype you created is located in your local maven repo,
you have to provide
-DarchetypeGroupId
,-DarchetypeArtifactId
,-DarchetypeVersion
formvn archetype:generate
. -DgroupId
,-DartifactId
,-Dversion
- these are groupId, artifactId, version of your future project.-DmyProjectName
- this one is just to show that any params can be added (if they are declared in requiredProperties) when you generate the project and their values will be used somewhere in the generated project (hopefully this makes some sense ))).-DinteractiveMode=false
- I am using it because the default value isTRUE
and when this interactiveMode is turned on you need to type some stuff manually when the project is being generated (it can be groupId, artifactId or so, or you just need to press Y to continue. Find more in the documentation or use as it is.)
That's it. Each time you change the archetype (updating descriptor) - you need mvn clean install
and mvn archetype:generate ...
.
It is also possible to create multimodule project, but it's not here. Just don't have time. But it should be easy to do, having this as an example.