我正在尝试向我的原型(prototype)添加其他变量。具体来说,我的原型(prototype)包含一个 logback.xml 文件,我想用我从原型(prototype)生成的项目的名称填充日志文件名。
我正在执行此处答案中的说明 Passing extra properties to maven archetype:generate ,但它说将 <requiredProperties>
元素添加到我的 archetype-metadata.xml 中。我的原型(prototype)没有 archetype-metadata.xml,它只有一个 archetype.xml (当我从 maven-archetype-archetype 生成原型(prototype)时自动生成)。
在 https://maven.apache.org/guides/mini/guide-creating-archetypes.html 中,Maven 将 archetype.xml 称为 Artifact 描述符。
我用谷歌搜索了 archetype-metadata.xml,并找到了这个 - http://maven.apache.org/archetype/archetype-models/archetype-descriptor/archetype-descriptor.html 。 Maven 也将其称为原型(prototype)描述符,但其规范不包含我在 archetype.xml 中看到的 id 和 resources 元素。
archetype.xml 和 archetype-metadata.xml 是同一件事吗?如果不是,它们的不同目的是什么?我可以将 <requiredProperties>
元素添加到 archetype.xml 文件中吗?或者我应该创建一个 archetype-metadata.xml 文件?
最佳答案
上面接受的答案的主要内容是使用 archetype-metadata.xml 而不是 archetype.xml,并带有 <requiredProperties>
元素,以及 <filesets>
我想要包含的资源的元素。在 archetype.xml 中,它是 <resources>
标签。还给原型(prototype)一个 <packaging>maven-archetype</packaging>
.
仍然不完全清楚 archetype.xml 和 archetype-metadata.xml 之间的区别。假设 archetype.xml 已被弃用?
关于maven - Maven中archetype.xml和archetype-metadata.xml有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36342578/