将生成的构建文件添加到类路径
在构建过程中,我通过包含构建信息的 Maven 属性插件 (properties-maven-plugin) 生成 build.properties 文件。
将此文件包含在生成的 jar 中的最佳方法是什么?我不想将其放入 src/main/resources 目录,因为这会污染我的默认资源目录。
是否没有像源代码那样的“生成资源”目录?
During my build I generate a build.properties files via the maven properties plugin (properties-maven-plugin) containing build information.
What's the best way to have this file included in the generated jar? I don't want to put it into the src/main/resources directory as this would pollute my default resource directory.
Is there not a "generated-resources" directory as there is with source?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我认为有一个默认的
generated-resources 目录,但目前我找不到任何相关文档。您始终可以在 pom 中配置其他资源目录:
I thought there was a default
generated-resources
directory, but I can't find any documentation on that at the moment. You can always configure additional resource directories in your pom:将生成的源放在 target/ generated-sources
有一个名为 build-helper 允许您将该文件夹添加到源文件夹列表中。
Place generated sources in target/generated-sources
There is a plugin called build-helper that allows you to add that folder to the source-folders list.
您可以使用 Maven 程序集插件来组织包中的文件和文件集。看看 http://maven.apache.org /plugins/maven-assemble-plugin/advanced-descriptor-topics.html
我认为这就是你所需要的。
You can use maven assembly plugin to organize files and filesets in packages. have a look at http://maven.apache.org/plugins/maven-assembly-plugin/advanced-descriptor-topics.html
I think it is what you need.
您可以将文件输出到任何目录,并将该资源目录添加到
的
中you can output your files to any directory and add that resource directory to your
<resources>
of your<build>
您应该将其放在
target/classes
目录中(现在仅从 target 修复),我认为这比公认的要好。因为不再需要将此资源作为资源处理
You should put it in the
target/classes
directory(fixed now from just target) and I think that this is better than the accepted one. As there is no need to process this resource as resource anymore