英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论