maven - Maven中archetype.xml和archetype-metadata.xml有什么区别

标签 maven

我正在尝试向我的原型(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/

相关文章:

maven - 使用 Maven 包含 JAXB

java - 使用 jlink 为外部 JAR 生成模块信息

maven - 如何确定从 Maven react 器计划构建了哪些 Artifact (即 : including sub modules)?

jsf - JSF 2 和 IceFaces 2 的 Maven 依赖项

maven - 在maven : copy,上运行Ant任务删除项目内的文件

maven - 使用 lombok 时由 : java. lang.ClassNotFoundException : com. sun.tools.javac.code.TypeTags 引起

maven - 在 Tomcat 上阅读电子邮件 : ClassNotFoundException: javax. mail.MessagingException

java - NoSuchMethodError : buildSessionFactory using Hibernate 5. 1.0 和 c3p0

plugins - 如何将 Maven 插件上传到 Nexus 存储库?

java - Maven包错误: No compiler is provided in this environment