-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transitive dependencies missing in compilation #132
Comments
Current state is that strict deps are emulated, proper dep analysis is required before the transitive classpath can be presented to the compiler. I am using the The good news is the last couple of days I have been working on strict dep support. This means adapting the kotlin compiler environment and adding compiler extensions. One such extension is strict dep analysis. I am now working on the analysis code. I am not a compiler engineer so it's trial and error. After I get kotlin to do a proper analysis it needs to be integrated with strict dep analysis performed by javac. I'll look into using the turbine compiler from bazel in place of javac if it's not too hard. I've got wip commits that update the rules with the various strict dep modes |
I've just run smack into this, and it applies even to java compiled by the kotlin compiler, so it's a problem for migration. A property of JavaInfo was added for scala's strict deps analysis, which is transitive_compile_time_deps, and pivoting off that should help, as in my testing of the rxjava2 dep which requires reactive-streaming APIs (inherits from them), both jars are present in the transitive_compile_time_deps depset. (c.f. square/bazel_maven_repository#54) |
…ransitive deps are present. If B deps on A as a part of API, e.g. inheriting from a class, A must be in the compilation classpath. This case adds a java_library example and a kt_jvm_library example of just such a case (rxjava2's Flowable and reactive-streaming's Publisher). This succeeds in the java_library case, so it's clear bazel_maven_repository's construction of a JavaInfo is sound. It fails in kotlin (even java compiled by the kotlin rules' kotlinc invocation) because it has half-baked strict-deps support, and ends up not consuming the proper classpath. Because it fails, it's commented out with a note pointing at the issue bazelbuild/rules_kotlin#132. This can be commented out at hte point where it's fixed.
…ransitive deps are present. If B deps on A as a part of API, e.g. inheriting from a class, A must be in the compilation classpath. This case adds a java_library example and a kt_jvm_library example of just such a case (rxjava2's Flowable and reactive-streaming's Publisher). This succeeds in the java_library case, so it's clear bazel_maven_repository's construction of a JavaInfo is sound. It fails in kotlin (even java compiled by the kotlin rules' kotlinc invocation) because it has half-baked strict-deps support, and ends up not consuming the proper classpath. Because it fails, it's commented out with a note pointing at the issue bazelbuild/rules_kotlin#132. This can be commented out at hte point where it's fixed.
Bumping up against this as well. I hit a blocker: grpc-java is structured with internal transitive dependencies that are flagged as private, so Bazel won't allow depending on them directly. I set up a small reproduction here: https://github.com/CoopeyB/bazel-kotlin-deps-bug Looks like this specific issue was discussed over a year ago: grpc/grpc-java#4258 - @hsyed, has there been any resolution to this? |
…path. Currently, because there's no strict deps mechanism, that means basically use the full transitive closure. This fixes (or works around) but bazelbuild#132
…le classpath. Currently, because there's no strict deps mechanism, that means basically use the full transitive closure. This fixes (or works around) but bazelbuild#132" This reverts commit 2d86189.
Fixed as of #205 |
…path. Currently, because there's no strict deps mechanism, that means basically use the full transitive closure. This fixes (or works around) but bazelbuild#132
…path. Currently, because there's no strict deps mechanism, that means basically use the full transitive closure. This fixes (or works around) but bazelbuild/rules_kotlin#132
It seems like it was hardcoded to be always in https://bazel.build/reference/command-line-reference#flag--experimental_strict_java_deps |
This is reported in pubref/rules_kotlin#47 with no resolution, but I don't see any discussion in the context of the new fork. It seems pretty significant, so I thought I'd raise it. Apologies if it is discussed elsewhere and I missed it.
kt_jvm_library
seems to omit transitive dependencies when compiling, requiring many more things to be declared as directdeps
compared tojava_library
.Here are some reproducers:
https://gist.github.com/jfancher/e56cdd806c3241177267c6542943c54d
https://gist.github.com/jfancher/d9db1a94277ae898aa3c0e6e2a1e3483
In both of these,
bazel build //:third
fails without adding:first
as a dep, due toC0
not being on the compilation classpath. In both cases the equivalent Java code andjava_library
declarations would be fine.Any plans or opportunities to improve this? Is it blocked on Skylark support? bazelbuild/bazel#4549 seems related but it's not clear to me whether there's a blocker for this simple use case or just more advanced Kotlin-specific features (it seems framed as the latter).
The text was updated successfully, but these errors were encountered: