Maven在构建JAR文件时要求包含文件。

huangapple go评论58阅读模式
英文:

Maven require inclusion of file when building JAR file

问题

我需要在Maven构建的JAR文件中包含一个文件。
所以我按照这个参考文档的步骤,在我的pom.xml中添加了一个<includes>元素:https://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html

然而,这样做只会在文件存在时包含它 - 我需要将这个文件设定为最终JAR文件的必需项。有没有办法指定文件的包含是强制性的?

英文:

I need to include a file in the built JAR file from Maven.
So I followed this reference doc and added an <includes> element in my pom.xml: https://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html

This however includes the file if it exists - I need to make this file a requirement for the end result JAR file. Is there a way to specify that the inclusion of the file is mandatory?

答案1

得分: 1

你可以尝试一个强制规则:

https://maven.apache.org/enforcer/enforcer-rules/requireFilesExist.html

这会检查文件是否存在,否则会中断构建。

英文:

You can try an enforcer rule:

https://maven.apache.org/enforcer/enforcer-rules/requireFilesExist.html

This checks whether a file exists and breaks the build otherwise.

huangapple
  • 本文由 发表于 2020年8月10日 15:43:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/63336039.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定