Proposal: Add modify_classpath to JavaInfo
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- java
- 領域
- build-system
調査の方向性
まず、modify_classpath を公開するモジュールファイルのパッチを確認し、現在の JavaInfo および java_common.merge の動作と比較します。jar の除外と、コンパイル時または実行時の jar の追加が、返される JavaInfo にどのような影響を与えるべきかを定義し、その後、本番向けに仕上げて pull request を作成する前に設計を検証します。
索引モデルが issue の本文から書いたものです。
説明
Context
We maintain a large Monorepo for multiple JVM languages that allows for multiple versions of external dependencies.
When JavaInfo objects are merged, the version that ends up on the classpath depends on the order that dependencies were declared in the 'deps' field (and other similar fields, such as exports and runtime_deps).
This can lead to situations where a target may depend directly on MyLibrary-1.0, but a different dependency appearing earlier in 'deps' transitively bring in MyLibrary-2.0. The version resolved on the classpath will be MyLibrary-2.0, despite the desired version being MyLibrary-1.0.
Proposal
Our module file adds a patch file that exposes a new method in JavaInfo called 'modify_classpath'. The method accepts a JavaInfo object and constructs a new JavaInfo object with selected jars pruned from the classpath. This is the method header:
def modify_classpath(java_info, exclude_jars = [], add_compile_jars = [], add_runtime_jars = []):
"""Returns a copy of the given JavaInfo with modified compile and runtime classpaths.
Enables classpath manipulation: excluding specific jars and/or adding new jars to the compile-time
and runtime classpaths.
Args:
java_info: (JavaInfo) The JavaInfo to modify.
exclude_jars: ([File]) Jars to remove from all classpath fields.
add_compile_jars: ([File]) Jars to prepend to the compile-time classpath.
add_runtime_jars: ([File]) Jars to prepend to the runtime classpath.
Returns:
(JavaInfo) A new JavaInfo with the modified classpaths.
Our call flow is essentially:
dep_java_infos = [dep[JavaInfo] for dep in ctx.attr.deps if JavaInfo in dep]
merged_java_info = java_common.merge(dep_java_infos)
pruned_java_info = java_common.modify_classpath(merged_java_info, exclude_jars = exclude_jars)
This enables selective exclusion of MyLibrary-2.0 from the merged JavaInfo object, allowing MyLibrary-1.0 to be resolved on the classpath
We have a working proof of concept. We would appreciate high-level feedback before productionizing and creating the PR.
Thank you!
- 主要言語
- Starlark
- スター
- 103
- フォーク
- 102
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bazelbuild/rules_java のほかの issue
-
P4
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
bazelbuild/rules_java#360 · コメント 4 件 · リアクション 2 件 ·
-
P3 question
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
bazelbuild/rules_java#339 · コメント 1 件 ·
-
P3
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
bazelbuild/rules_java#325 · コメント 8 件 ·
-
P4
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
bazelbuild/rules_java#316 · リアクション 2 件 ·
-
P2
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
bazelbuild/rules_java#289 · コメント 1 件 ·
bazelbuild/rules_java の issue をすべて見る
似ている issue
-
type/automation type/tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
priority: p3
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
googleapis/librarian#7636 ·
-
package-update
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
oSoWoSo/vOid_Community_repOsitory#147 · コメント 1 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
agentic-workflows cascade-suspected
難易度 1/5 1時間未満 初心者へのやさしさ 88/100