从Maven原型生成模块时访问父属性 [英] Accessing parent properties when generating a module from a Maven archetype
问题描述
我有许多Maven原型,正在使用它们来生成多模块Maven项目.
I have a number of maven archetypes which I am using to generate a multi-module maven project.
我具有用于生成父项目的原型的必需属性.它将作为属性添加到项目的pom.xml中.
I have a required property on the archetype I use to generate the parent project. This gets added as a property in the pom.xml for the project.
然后,我使用不同的原型在项目内生成一个模块.我希望在该模块的某些资源中替换相同的值.
I then generate a module within the project, using a different archetype. I would like the same value to be substituted within some of the resources in that module.
在调用第二个原型时,再次将其作为属性提供似乎是错误的.
It seems wrong to supply it as a property again when calling the second archetype.
是否可以在模块的原型生成过程中引用父项目属性?我希望将值替换为模块的src树中的文件,而不要使用占位符,以便在目标文件夹中替换该值.
Is it possible to reference parent project properties during the archetype generation process for the module? I want the value to be substituted into files in the src tree of the module, not use a place holder so that it is substituted in the target folder.
感谢您的帮助.
推荐答案
在Maven 3中,您可以通过${project.parent.x}
访问父级属性.
In Maven 3, you can access parent properties by ${project.parent.x}
.
更多信息可以在 Maven属性指南中找到.
More information can be found in the Maven Properties Guide.
这篇关于从Maven原型生成模块时访问父属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!