Propagate .jdeps for java_import#363
Conversation
1c5b6ea to
bbf650b
Compare
java_import participate in Java classpath reduction.jdeps for java_import
bd8f649 to
1de17e5
Compare
|
|
||
| # Default java_toolchain parameters | ||
| _BASE_TOOLCHAIN_CONFIGURATION = dict( | ||
| deps_checker = Label("@remote_java_tools//:ImportDepsChecker"), |
There was a problem hiding this comment.
This is a breaking change for Bazel as the hardcoded mode is error. Can I add a new attribute that makes it configurable on the toolchain level? I can set the default to silence to match the current behavior or to error as a breaking change with a simple migration.
Are you precompiling the tool to a native image at Google?
There was a problem hiding this comment.
Are you precompiling the tool to a native image at Google?
It's a prebuilt jar that runs on the JVM, but it's also a validation action that is not on the critical path (#362 (comment)).
Using a native image seems like a good idea if it's going to run as a non-validation action so the .jdeps can be used for reduced classpaths.
There was a problem hiding this comment.
Can I add a new attribute that makes it configurable on the toolchain level?
Bazel supports tags = ["incomplete-deps"] on java_import. Having a real attribute (on the toolchain and/or individual java_imports) is probably better than leaning on tags for this.
cc @hvadehra
There was a problem hiding this comment.
My main concern is that external repos using java_import would be very difficult to opt out unless there is a global (toolchain) switch.
1206db6 to
14e031c
Compare
With `--experimental_java_classpath=bazel_no_fallback` (and as a double-compilation pessimization under the default `bazel` mode), a `java_import` defeated the reduced-classpath optimization for every target depending on it. Unlike a `java_library` header jar, which is built by turbine (emitting a jdeps and repackaging the supertype closure), a `java_import` interface jar is built by ijar and contributed no compile-time dependency artifact, so downstream reduced classpaths pruned the import's transitive jars. `java_import` now runs `ImportDepsChecker` (newly wired into the default toolchain's `deps_checker`) over its jars and propagates the resulting jdeps proto as `compile_jdeps`. The checker records the full transitive supertype closure, so this is correct for supertype chains of any depth. It runs in `silence` mode (purely additive, never a new build failure) and only when the import has deps/exports; the jdeps is consumed lazily. Fixes bazelbuild#362
14e031c to
08211fd
Compare
Downstream Java compilation actions need accurate
.jdepsfiles for their reduced classpath optimization. With this change,java_importnow always runsImportDepsCheckerto generate this file, but possibly suppresses its outputs.Fixes #362