如何将我的资源节与超级POM的资源节合并?(How can I merge my resources stanza with that of the super POM?)

编程入门 行业动态 更新时间:2024-10-28 10:32:59
如何将我的资源节与超级POM的资源节合并?(How can I merge my resources stanza with that of the super POM?)

(我和Maven一起工作了很多年。我有点不敢相信我现在才遇到这个问题。)

超级POM定义了它的<resources>节,如下所示:

<resources> <resource> <directory>${project.basedir}/src/main/resources</directory> </resource> </resources>

我在我的pom.xml有一个<resources>节,如下所示:

<resources> <resource> <directory>${project.basedir}</directory> <includes> <include>LICENSE</include> </includes> <targetPath> </resource> </resource>

当我运行mvn help:effective-pom ,我可以看到Maven已经删除了超级POM(有用的) <resources>节,并将其替换为我自己的节。

相反,我想将我的<resources>节的内容添加到超级POM提供的内容中。

没有放在我的<resources>元素上的combine.children或combine.self属性的组合导致这种情况发生(加上我不知道这些名称应该表示什么,尽管我已阅读有关该主题的文章 ) 。

我错过了什么明显的事情?

(I've been working with Maven for many years. I sort of can't believe I've only now encountered this issue.)

The super POM defines its <resources> stanza like this:

<resources> <resource> <directory>${project.basedir}/src/main/resources</directory> </resource> </resources>

I have a <resources> stanza in my pom.xml like this:

<resources> <resource> <directory>${project.basedir}</directory> <includes> <include>LICENSE</include> </includes> <targetPath> </resource> </resource>

When I run mvn help:effective-pom, I can see that Maven has eliminated the super POM's (helpful) <resources> stanza and has replaced it with my own.

Instead, I'd like to add the contents of my <resources> stanza to that supplied by the super POM.

No combination of either of the combine.children or combine.self attributes placed on my <resources> element causes this to happen (plus I have no idea what these names are supposed to indicate, though I've read an article on the subject).

What obvious thing am I missing?

最满意答案

像combine.children和combine.self这样的神奇属性仅适用于插件的配置; pom本身被转换为一组pojos,但插件配置是一个XML-DOM。 使用xpp3功能,我们可以定义合并策略。 是的,AFAIK资源总是被覆盖,永远不会扩展。 资源没有唯一标识符,因此无法检测应合并,覆盖或扩展哪些资源块。

The magic attributes like combine.children and combine.self only apply on the configuration of plugins; the pom itself is transformed to a set of pojos, but the plugin-configuration is a XML-DOM. With xpp3 features we can define a merge strategy. And yes, AFAIK resources are always overwritten, never extended. A resource doesn't have a unique identifier, so it is not possible to detect which resource-blocks should be merged, overridden or extended.

更多推荐

本文发布于:2023-08-06 03:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1444384.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:资源   如何将   POM   merge   stanza

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!