如何在巴泽尔指定Java Meta-Inf目录和服务?
我正在尝试提供自己的system.loggerfinder
的实现,据我所知,我必须在某些资源文件/resources/Meta-inf/services/java中指定类。 Lang.System $ LoggerFinder
。
现在,我的实现位于其自己的软件包中(包括构建文件和java_library()
(通常),这与软件包&构建文件我的java_binary()
生活在中。我将实现为deps
添加到二进制文件的构建文件中,并确保使用//可见软件包可见:public
只是为了确保这不是问题。我尝试将上述文件放入两个文件中,并使用resources = [“ Resources/Meta-Inf/services/java.lang.system $ loggerfinder”将其指定为资源文件。]
,但巴泽尔总是抱怨
- 文件
'//:resources/meta-inf/services/java.lang.system.system $ loggerfinder'
', - 或者,如果我使用
resources = [“ //resources/meta-inf/services/java.lang.systemqulfinder”]
而不是资源目录缺少构建文件。
因此,我的问题基本上是:我必须在哪里放置资源,以及如何指定它们?如果我必须在资源中添加构建文件,我应该使用什么规则?
谢谢!
I am trying to provide my own implementation of the System.LoggerFinder
and as far as I know I have to specify the class in some resource file /resources/META-INF/services/java.lang.System$LoggerFinder
.
Now my implementation is located in its own package (Including build file and java_library()
as rule), which is different from the package & BUILD file my java_binary()
lives in. I added the implementation as deps
to the BUILD file of the binary and made sure the package is visible using //visibility:public
just to make sure that's not the problem. I tried putting the above mentioned file into both of them and specifying it as resource file in the respective BUILD file using resources = ["resources/META-INF/services/java.lang.System$LoggerFinder"]
, but bazel always complains that either
- the file
'//:resources/META-INF/services/java.lang.System$LoggerFinder'
is missing, - or, if I use
resources = ["//resources/META-INF/services/java.lang.System$LoggerFinder"]
instead, that the the resource directory is missing a BUILD file.
So basically my question is: Where do I have to put the resources and how do I have to specify them? If I have to add a BUILD file to the resources what rule should I use?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是在Meta-Inf文件夹中使用文件创建一个JAR文件,并将其添加为Java_library的依赖性。罐子的内容应合并。类似的东西:
One way to do this is to create a jar file with the files in the META-INF folder and add that as a dependency of your java_library. The contents of the jar should be merged in. Something like this: