bazel-contrib / bazel-contrib/rules_scala
Be able to generate service provider configuration for targets that host service implementations
- Dominant language
- Starlark
- Stars
- 384
- Forks
- 292
- Avg merge
- 3d 3m
- Merged PRs (30d)
- 42
Description
### Description of the problem / feature request:
Be able to generate service provider configuration for targets that host service implementations. This automates maintenance of jvm service provider configuration files as described here:
https://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html
### Feature requests: what underlying problem are you trying to solve with this feature?
Currently, there is no way to add this information to the `scala_library` target so that the generation of this configuration is automated.
Proposal: to add a `services` attribute to `scala_library` for this additional information such that if its specified like:
```
scala_library(
...
services = {
"com.a.b": [
"com.a.b.ServiceInterface1",
"com.a.b.ServiceInterface2",
],
},
)
```
then this will result in a directory being created in the output jar: `META-INF/services`, and an additional text file per service interface listing the implementing classes like:
```
$ cat $output_jar/META-INF/services/com.a.b
com.a.b.ServiceInterface1
com.a.b.ServiceInterface2
```
### Any other information, logs, or outputs that you want to share?
Attaching a draft wip PR with this issue to kickstart the work and happy to hear thoughts/ideas.
Contributor guide
Research direction
Start with the scala_library rule and the Java ServiceLoader documentation linked in the issue. Implement the proposed services attribute so the output JAR contains META-INF/services and one file per service interface listing its implementing classes; verify the generated archive contents.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100