In Chapter 5, Maven Plugins, we discussed in detail how to develop Maven plugins. However, in all of those cases, we started from scratch, building everything from the project structure to everything by hand. Now, we will look at how to create a Maven plugin project with the archetype
plugin. Here, we use the maven-archetype-plugin
:
$ mvn archetype:generate -DgroupId=com.packt.samples -DartifactId=com.packt.samples.plugins.myplugin -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-plugin -DinteractiveMode=false
The previous command will produce the following directory structure and the source code. If you look at the pom.xml
file, you will notice that it contains all necessary instructions along with the required dependencies that are needed to build the Maven plugin project:
com.packt.samples.plugins.myplugin ...