質問

I created a Maven Archetype for use in our company projects. Everything worked well until going to deploy a project built from the archetype which failed due to invalid XML.

Within the template I created to generate the archetype from are several .xml files. Each has an XML declaration of:

<?xml version="1.0" encoding="UTF-8"?>

When running mvn archetype:create-from-project to stamp out the archetype for me, it apparently determined version in the XML declaration as a Maven keyword and wrapped it in a variable. The result was that each XML declaration in the archetype became:

<?xml ${version}="1.0" encoding="UTF-8"?>

After using the archetype to create a project, Maven obviously replaced this variable with the user-chosen version for the project. This resulted in something like:

<?xml 1.0-SNAPSHOT="1.0" encoding="UTF-8"?>

Definitely invalid for XML. My question then is, how can you prevent mvn archetype:create-from-project from doing this? Is there a way to limit its scope in some way or set a flag in the command line?

役に立ちましたか?

解決

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top