Right now I usually find a pom.xml
file on the web that has a pom
packaging and copy and paste it to create my parent project. Then I used to run archetype:create
inside the parent directory to create sub modules but archetype:create
has become deprecated since then.
Any recommendations on how to create new Maven multi-module projects?
Best Answer
The easiest way I've found to do this is to use the
pom-root
archetype to create the top-level pom and then repeatedly usearchetype:generate
to create each module individually. This will automatically add the modules to the root pom (aggregator) and set the root pom as the parent pom for each module (edit: apparently some archetypes can have a hard-coded parent, but it works formaven-archetype-quickstart
).Here's the breakdown:
Create the top-level root:
cd
into your newly created root dir.For each module:
Note that
-DarchetypeVersion=RELEASE
above will automatically use the latest version of the archetype. You may want to add-DgroupId=...
to each of those commands to avoid repeating yourself.