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!
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: