问题描述
我正在尝试向原型添加其他变量.具体来说,我的原型包含一个logback.xml文件,我想用我从该原型生成的项目的名称填充日志文件名.
I'm trying to add additional variables to my archetype. Specifically, my archetype contains a logback.xml file, and I want to populate the log filename with the name of the project I'm generating from the archetype.
我正在此处的答案中执行说明将其他属性传递给Maven原型:生成,但是它说要在我的archetype-metadata.xml文件中添加一个<requiredProperties>
元素.我的原型没有archetype-metadata.xml,它只有一个archetype.xml(当我从maven-archetype-archetype生成原型时自动生成).
I was carrying out the instructions in the answer here Passing extra properties to maven archetype:generate, but it says to add a <requiredProperties>
element to my archetype-metadata.xml. My archetype doesn't have an archetype-metadata.xml, it only has an archetype.xml (which was generated automatically when I generated my archetype from maven-archetype-archetype).
在 https://maven.apache.org/guides/mini中/guide-creating-archetypes.html ,Maven将archetype.xml称为工件描述符.
In https://maven.apache.org/guides/mini/guide-creating-archetypes.html, Maven refers to archetype.xml as an artifact-descriptor.
我搜索了archetype-metadata.xml,并找到了它- http://maven.apache.org/archetype/archetype-models/archetype-descriptor/archetype-descriptor.html . Maven也称其为原型描述符,但其规范不包含我在archetype.xml中看到的id和resources元素.
I googled archetype-metadata.xml, and found this - http://maven.apache.org/archetype/archetype-models/archetype-descriptor/archetype-descriptor.html. Maven calls it an archetype-descriptor as well, but its specification does not contain the id and resources elements that I see in my archetype.xml.
archetype.xml和archetype-metadata.xml是否相同?如果没有,他们的目的是什么?可以在我的archetype.xml文件中添加一个<requiredProperties>
元素吗?还是应该创建一个archetype-metadata.xml文件?
Are archetype.xml and archetype-metadata.xml the same thing? if not, what are their different purposes? Can I add a <requiredProperties>
element to my archetype.xml file? Or should I create an archetype-metadata.xml file?
推荐答案
您应该按照我在上述文章中的建议创建原型描述符(archetype-metadata.xml),将额外的属性传递给maven原型:generate
You should create the archetype descriptor (archetype-metadata.xml) as I suggested in the mentioned post,Passing extra properties to maven archetype:generate
以下是我正在执行的生成项目的步骤:
Here are the steps that I'm executing to generate the project:
mkdir temp
cd temp
git clone [email protected]:jibbyj/appArchetype.git
cd appArchetype
mvn clean install
mkdir run01
cd run01
ls
mvn archetype:generate \
-DarchetypeGroupId=com.company.archetype \
-DarchetypeArtifactId=appArchetype \
-DarchetypeVersion=1.2-SNAPSHOT \
-DarchetypeCatalog=local \
-DinteractiveMode=false \
-DgroupId=com.company \
-DartifactId=test \
-DappName=test
此流程完成后,可以在测试文件夹中找到生成的项目.
after this flow is completed, in test folder you can find the generated project.
在pom.xml
中,artifactId设置为"test",也在src/main/resources/logback.xml
中进行替换.
In the pom.xml
, the artifactId is set to the "test", also in src/main/resources/logback.xml
the substitution is made.
这篇关于Maven中archetype.xml和archetype-metadata.xml有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!