我正在尝试将其他变量添加到我的原型中.具体来说,我的原型包含一个logback.xml文件,我想用日志文件名生成我正在生成的项目名称.
我正在执行答案中的说明将额外的属性传递给maven archetype:generate,但是它说要<requiredProperties>在我的archetype-metadata.xml中添加一个元素.我的原型没有archetype-metadata.xml,它只有一个archetype.xml(当我从maven-archetype-archetype生成我的原型时自动生成).
在https://maven.apache.org/guides/mini/guide-creating-archetypes.html中,Maven将archetype.xml称为工件描述符.
我用google搜索archetype-metadata.xml,发现了这个 - http://maven.apache.org/archetype/archetype-models/archetype-descriptor/archetype-descriptor.html.Maven也称它为原型描述符,但它的规范不包含我在archetype.xml中看到的id和resources元素.
archetype.xml和archetype-metadata.xml是一回事吗?如果没有,他们的目的是什么?我可以在<requiredProperties>archetype.xml文件中添加一个元素吗?或者我应该创建一个archetype-metadata.xml文件?
您应该创建原型描述符 (archetype-metadata.xml),正如我在提到的帖子 将额外属性传递给 Maven archetype:generate 中所建议的那样
以下是我生成项目所执行的步骤:
mkdir temp
cd temp
git clone git@github.com: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
Run Code Online (Sandbox Code Playgroud)
此流程完成后,在 test 文件夹中您可以找到生成的项目。
在 中pom.xml,artifactId 设置为“test”,也在src/main/resources/logback.xml进行替换。
| 归档时间: |
|
| 查看次数: |
1955 次 |
| 最近记录: |