rules_kotlin icon indicating copy to clipboard operation
rules_kotlin copied to clipboard

Example to repro jdeps issue

Open nkoroste opened this issue 3 years ago • 2 comments

Fails with jdeps:

cd examples/jdesp_issue
bazel build //libKtAndroid1:src_main_kt --@io_bazel_rules_kotlin//kotlin/internal/jvm:experimental_prune_transitive_deps=True --@io_bazel_rules_kotlin//kotlin/internal/jvm:kotlin_deps=True

Passes without jdeps:

cd examples/jdesp_issue
bazel build //libKtAndroid1:src_main_kt --@io_bazel_rules_kotlin//kotlin/internal/jvm:experimental_prune_transitive_deps=True --@io_bazel_rules_kotlin//kotlin/internal/jvm:kotlin_deps=False

Error:

ERROR: /Users/nkorostelev/Snapchat/Dev/rules_kotlin/examples/jdesp_issue/libKtAndroid1/BUILD.bazel:3:19: KotlinCompile //libKtAndroid1:src_main_kt { kt: 1, java: 0, srcjars: 0 } for darwin_arm64 failed: (Exit 1): build failed: error executing command (from target //libKtAndroid1:src_main_kt)
  (cd /Users/nkorostelev/Snapchat/Dev/.cache/bazel/arm64/f7a5653e44abf3a0528c8c383a926394/execroot/__main__ && \
  exec env - \
    LC_CTYPE=en_US.UTF-8 \
    REPOSITORY_NAME=io_bazel_rules_kotlin \
  bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/io_bazel_rules_kotlin/src/main/kotlin/build '--flagfile=bazel-out/darwin_arm64-fastbuild/bin/libKtAndroid1/src_main_kt-kt.jar-0.params')
# Configuration: 3222cb75a37bee8592598dc8e5437da815dc34e08dd4cee307b00b4cc8e60a77
# Execution platform: @local_config_platform//:host
error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
    class examples.deps.libktandroid2.KtDummy2, unresolved supertypes: examples.deps.libktandroid3.KtDummy3
Adding -Xextended-compiler-checks argument might provide additional information.

Probably caused by https://github.com/bazelbuild/rules_kotlin/pull/807

In theory, I think if the build doesn't fail without jdeps then it should also not fail with jdeps - @aeremin thoughts?

nkoroste avatar Oct 28 '22 00:10 nkoroste

Probably caused by https://github.com/bazelbuild/rules_kotlin/pull/807

I no longer think that this PR is an issue. As it fails just the same when I revert it.

nkoroste avatar Nov 01 '22 00:11 nkoroste

Correct. Issue is not caused by https://github.com/bazelbuild/rules_kotlin/pull/807, it's caused by JdepsGenExtension invoking supertypes() kotlintype API (here). This call will cause (lazy) resolution of the type, and will cause an error since corresponding class is missing on classpath.

Why is compilation succeed then? See Pavel's comment on this issue

having a type with missing supertypes doesn't always mean that the old error will be reported

So, your best bet is to fix your project and add the missing dep :(

oliviernotteghem avatar Nov 03 '22 17:11 oliviernotteghem