bazelbuild / bazelbuild/rules_java

Add better support for generated resources

未关闭
#275 9 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
P3
主要语言
Starlark
星标
103
派生
102
PR 合并指标
30 天内没有已合并 PR

描述

[`java_library.srcs`](https://bazel.build/reference/be/java#java_library.srcs) supports `.srcjar` files to facilitate including generated sources. `.properties` files included in `java_library.srcs` are filtered and included in `java_library.resources`. Consider extending the current behaviour so that `.properties` files included in `.srcjar` files are also included in `java_library.resources`. This will facilitate the usage of generated resources.

For example, I have a `genrule` that generates `.java` and `.properties` files and I don't necessarily know all of them during the analysis phase for declaration purposes. For this reason, my rule instead generates a `.srcjar` file. However, the `.properties` files inside that `.srcjar` file are being skipped.

There are other alternative ways of going about it:

- There's already an internal [`resource_jars`](https://github.com/bazelbuild/rules_java/blob/8.9.0/java/common/rules/impl/basic_java_library_impl.bzl#L95) field that could perhaps be reused for this effect (at the moment it seems to always be forced as empty)? However, straight including `.srcjar` files in this field won't achieve the desired outcome as this can result in `.java` files appearing inside the final `.jar` file. Maybe somehow expose this field to users?

- Support something like `.resourcejar` files in `java_library.resources`. This would be a breaking change :pensive:.

贡献指南

打开贡献指南

调研方向

首先阅读 resource_jars 字段附近的 java/common/rules/impl/basic_java_library_impl.bzl,并跟踪 java_library.srcs 和 java_library.resources 如何处理生成的输入。比较提出的方案,并将完成后的行为定义为:保留 Java 源文件,同时包含在 .srcjar 输出内部找到的 .properties 文件。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
build-system
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。