Wednesday, May 18, 2016

Maven Archetypes

I have been using Maven for a long while now. It's great for dependency management, and packaging my applications. Even though in many areas I see movement towards Gradle, I don't think that Maven is going anywhere anytime soon. Maven has the concept of Archetypes; these allow anyone to create a project very simply including a good amount of the folder structure (Although any directory you want to have needs to have a file.)

I have used archetypes a number of times in the past, but I never created any. Recently I kept thinking to myself that I needed a way to generate a project without needing to do it by hand. For some reason in my mind I never made the connection that I could just create my own. However, something clicked and suddenly I decided that I wanted to create my own. Using the Maven guide, I had one made up in a matter of 20 minutes. Most of that time was spent making my own customizations that I wanted for the specific type of project. The actual initialization of the archetype definition was extremely easy.

Oddly enough the people who came up with archetypes were kind enough to even come up with an archetype for the archetype.

Using the below code you can get your own archetype started:

mvn archetype:generate
  -DgroupId=[your project's group id]
  -DartifactId=[your project's artifact id]

Happy Archetyping!

1 comment:

Unknown said...

Thanks for sharing