向Maven Pom添加其他资源 [英] adding additional resources to a maven pom
问题描述
我定义了一个超级pom,在其中我为资源指定一个"resources"目录.在我的一个项目中,我的pom扩展了该超级pom,我想添加一个额外的资源.我试过了:
I have a super pom defined in which I specify a "resources" directory for resources. In one of my projects, my pom extends that super pom, and I would like to add an additional resource. I tried:
<resources>
<resource>
<targetPath>/</targetPath>
<directory>additionalDir</directory>
</resource>
</resources>
但是,这只会导致 附加ID出现在资源中,并且不包括超级pom的资源.有没有办法扩展超级pom的资源?
But that results in only additionalDir being in the resources and does not include the super pom's resources. Is there a way to extend the super pom's resources?
推荐答案
您所描述的行为是预期的.
The behaviour you've described is expected.
请记住,您的超级POM是从Maven的默认值继承的POM 以及您在pom中定义的几乎所有插件都将有效地覆盖默认POM中的设置.例如,要对默认资源启用筛选,必须在POM中指定路径.您可以这样做:
Remember that your super POM is inheriting from Maven's default POM and pretty much any plugin that you define in your pom effectively overrides the setting in the default POM. As an example, to enable filtering on the default resource, you have to specify the path in your POM. You do this:
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
不是这样的:
<resources>
<resource>
<filtering>true</filtering>
</resource>
</resources>
即使您已在其中指定默认目录,默认目录也不会为您显示.可能会有一种特殊的MOJO可以为您完成,但是我找不到.
The default directory does not bubble up for you, even if you've specified it there. There might be a special MOJO to do it for you, but I couldn't find one.
这篇关于向Maven Pom添加其他资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!