Making a Maven Archetype

3 09 2008

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:

  1. Build a project that will act as a template for the archetype
  2. run mvn archetype:create-from-project , from the project folder
  3. Edit the generated archetype ( placed in target/generated-sources/archetype ), it might not pickup on everything that needs to be substituted.
  4. From target/generated-sources/archetype of the project template run mvn install
  5. Try the archetype yourself by running mvn archetype:generate -DarchetypeCatalog=local from a fresh directory
  6. Repeat the process until satisfied

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


Happy Archetyping:)




4 responses

17 01 2009

Hi Nino,

Great tip here, thanks.

I have encountered a couple of problems when trying to follow the steps above and I wonder if you have any pointers on how to resolve things.

Firstly, when running mvn archetype:create-from-project I get the following error.

[INFO] Cannot create archetype from this project.

Embedded error: /home/emalethan/work/zzmalethan_blog/seemorej-hibernate-archetype-template/src/main/archetype/ (No such file or directory)

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

…[INFO] [archetype:create-from-project]
at org.apache.oro.text.regex.Perl5Compiler.compile(
at org.apache.maven.archetype.FilteringCopier.copy(
at org.apache.maven.archetype.FileUtils.copyFile(
at org.apache.maven.archetype.FileUtils.copyFileToDirectory(

I can’t find much by Googling. I’d be grateful for any pointers?



25 01 2009

Hmm that’s a bit wierd, what kind of project are it, war / jar or?

But notice that both problems are actually only INFO’s…

24 02 2009

I got the same error, but resolved when using newer version of archetype plugin.

try 2.0-alpha-4 of maven-archetype-plugin by specifying the version in pom.xml


12 03 2009
Maven Troubles

[…] as per Nino Martinez’s tip I used mvn archetype:create-from-project to attempt to create an archetype from my example […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: