bazelbuild / bazelbuild/rules_java

Add better support for generated resources

オープン
#275 コメント 9 件 リアクション 0 件 担当者 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:.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start by reading java/common/rules/impl/basic_java_library_impl.bzl around the resource_jars field and trace how java_library.srcs and java_library.resources handle generated inputs. Compare the proposed approaches and define the completed behavior as preserving Java sources while including .properties files found inside .srcjar outputs.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
build-system
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。