Making a Maven Archetype

3092008

So I want to create a maven archetype. My first run at this were a couple of months ago, it were pretty hard but then again I built the archetype from scratch.

I use userlist’s a lot so and though that it were very awkward how I did the previous archetype. So I wrote maven user list asking and theres actually a maven goal for it. So you can create an archetype in 6 steps:

Build a project that will act as a template for the archetype

run mvn archetype:create-from-project , from the project folder

Edit the generated archetype ( placed in target/generated-sources/archetype ), it might not pickup on everything that needs to be substituted.

From target/generated-sources/archetype of the project template run mvn install

Try the archetype yourself by running mvn archetype:generate -DarchetypeCatalog=local from a fresh directory

Repeat the process until satisfied

Now this also works for projects consistent of modules, a project structure like below:

When I add this file (empty, btw) I get a much bigger error, as follows.

…[INFO] [archetype:create-from-project]
java.lang.NullPointerException
at org.apache.oro.text.regex.Perl5Compiler.compile(Perl5Compiler.java:1954)
at org.apache.maven.archetype.FilteringCopier.copy(FilteringCopier.java:83)
at org.apache.maven.archetype.FileUtils.copyFile(FileUtils.java:797)
at org.apache.maven.archetype.FileUtils.copyFileToDirectory(FileUtils.java:749)