We would like to create a partial archetype to add a custom-pom.xml
as well as other resources into an existing project. The custom pom will then be used in the generated project via mvn -f custom-pom.xml
.
Our archetype therefore contains a src/main/resources/archetype-resources/osgi-pom.xml
, but does not contain a pom.xml
in the same directory.
We used archetype:generate
parameterised appropriately to run this archetype on an existing project. This produces:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: org.apache.maven.archetype.exception.ArchetypeGenerationFailure: Error merging velocity templates: Unable to find resource 'archetype-resources/pom.xml' -> [Help 1]
As a test, we created a dummy archetype-resources/pom.xml
then re-ran the generate
goal. This produces:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: Don't override file /tmp/archetype/fabric-rf-server/pom.xml -> [Help 1]
We saw this example which has no archetype-resources/pom.xml
. We are using the Archetype 2.0x standard however, which is possibly why the tactic works for that author but not ourselves.
How can we resolve this problem? Is a partial archetype unsuitable for inserting resources into an existing Maven project - must the project instead be non-Maven?
We've scoured the Maven Archetype plugin 2.2 documentation but there's barely any mention of partial archetypes and their specialised behaviour.