Search code examples
javamaven-3archetypes

Avoiding substitution of expressions archetype:create-from-project


Hey, could please anybody tell me how to avoid substitution of some expressions in a project when creating an archetype from it via archetype:create-from-project ?

for instance it substitutes all appearances of "1.0" expressions in the project with ${version}

if programmer creates the archetype from project of verion 1.0 <version>1.0</version> , then for instance header of an xml file

<?xml version="1.0"?>

changes to

<?xml version="1.0-SNAPSHOT"?> 

.... because there was <?xml version="${version}"?> in the archetype resources and users entered 1.0-SNAPSHOT as a project version

Also, is it possible to supply more arguments when creating project from the archetype? In addition to groupId, artifactId, package and version ?


Solution

  • You can add -Darchetype.filteredExtentions=extension1,extension2,... to your mvn command to tell maven which file extensions to include in its velocity substitutions. If you make a list of all of your file extensions and leave off xml, it should skip over them. You can do -Darchetype.filteredExtentions if xml is the only file type in your project.