There is an existing issue for this approach, located on Codehaus JIRA #ARCHETYPE-57, but all instructions listed in this ticket failed for me. Also the blog post of marekdec Ho
I did a quick test and... it worked for me. First, I created an archetype:
$ mvn archetype:generate -B -DarchetypeArtifactId=maven-archetype-archetype \
-DgroupId=com.stackoverflow \
-DartifactId=Q2786966 \
-Dversion=1.0-SNAPSHOT \
I renamed the archetype.xml
into archetype-metadata.xml
(the former is for Archetype 1.0.X, the later is for Archetype 2.0.X) so the project looks like:
$ tree . . ├── pom.xml └── src └── main └── resources ├── archetype-resources │ ├── pom.xml │ └── src │ ├── main │ │ └── java │ │ └── App.java │ └── test │ └── java │ └── AppTest.java └── META-INF └── maven └── archetype-metadata.xml
And archetype-metadata.xml
contains:
src/main/webapp
src/main/java
**/*.java
Then I installed the archetype and used it to create a project:
$ mvn install
$ cd ~/tmp
$ mvn archetype:generate -B -DarchetypeGroupId=com.stackoverflow \
-DarchetypeArtifactId=Q2786966 \
-DarchetypeVersion=1.0-SNAPSHOT \
-DgroupId=my.group \
-DartifactId=my-artifact \
-Dversion=1.0-SNAPSHOT
And the resulting project looks like this:
$ tree my-artifact/ my-artifact/ ├── pom.xml └── src └── main ├── java │ └── my-group │ └── App.java └── webapp
The empty webapp directory is there.