bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://ij.bazel.build/
Apache License 2.0
761 stars 303 forks source link

Cannot compile basic java project due to IJWB's aspects #6405

Closed niklassemmler closed 4 months ago

niklassemmler commented 4 months ago

Description of the bug:

I created a basic bazel Java project that includes Junit test cases. During the execution I run into the error Error: type 'depset' has no operator [](int). If I remove the following argument from the build process it works: --aspects=@@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect "--override_repository=intellij_aspect=/Users/niklassemmler/Library/Application Support/JetBrains/IdeaIC2022.3/plugins/ijwb/aspect"

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

git clone https://github.com/niklassemmler/java_bazel_proj

Then either run bash produce_error.sh

Or

  1. Import into Intellij
  2. Run build sync

Which Intellij IDE are you using? Please provide the specific version.

2022.3.2 (CE) / Build #IC-223.8617.56

What programming languages and tools are you using? Please provide specific versions.

Java, Junit, Bazel

What Bazel plugin version are you using?

2023.07.04.0.1-api-version-223 / bazel 7.1.1-homebrew

Have you found anything relevant by searching the web?

Not really.

Some sites recommend to set build --incompatible_depset_is_not_iterable=false but this doesn't work with my version of bazel

Any other information, logs, or outputs that you want to share?

The error output

Command: bazel build --tool_tag=ijwb:IDEA:community --keep_going --build_event_binary_file=/var/folders/4n/m79nj3h52m7_5fqmxxd0b1zm0000gn/T/intellij-bep-c2d2f481-d7c2-420b-86cc-f419b3a30ea8 --nobuild_event_binary_file_path_conversion --curses=no --color=yes --progress_in_terminal_title=no --noexperimental_run_validations --aspects=@@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect "--override_repository=intellij_aspect=/Users/niklassemmler/Library/Application Support/JetBrains/IdeaIC2022.3/plugins/ijwb/aspect" --output_groups=intellij-resolve-java-direct-deps,intellij-info-generic,intellij-info-java-direct-deps -- //:junit5-jupiter-starter-bazel //:Main //:src/test/java/com/test/OtherTest //:src/test/java/com/test/SomeTest
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Analyzing: 4 targets (0 packages loaded, 0 targets configured)
Analyzing: 4 targets (0 packages loaded, 0 targets configured)
[0 / 1] [Prepa] BazelWorkspaceStatusAction stable-status.txt
ERROR: /Users/niklassemmler/Documents/Proj/BUILD:11:13: in @@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect aspect on java_library rule //:junit5-jupiter-starter-bazel: 
Traceback (most recent call last):
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_bundled.bzl", line 67, column 37, in _aspect_impl
        return intellij_info_aspect_impl(target, ctx, semantics)
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 1144, column 32, in intellij_info_aspect_impl
        handled = collect_java_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 598, column 29, in collect_java_info
        jars = [library_artifact(output, ctx.rule.kind) for output in java_outputs]
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 168, column 48, in library_artifact
        source_jar = artifact_location(src_jars[0]) if src_jars else None,
Error: type 'depset' has no operator [](int)
ERROR: /private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/rules_jvm_external~~maven~maven/BUILD:352:11: in @@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect aspect on jvm_import rule @@rules_jvm_external~~maven~maven//:org_apiguardian_apiguardian_api: 
Traceback (most recent call last):
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_bundled.bzl", line 67, column 37, in _aspect_impl
        return intellij_info_aspect_impl(target, ctx, semantics)
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 1144, column 32, in intellij_info_aspect_impl
        handled = collect_java_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 598, column 29, in collect_java_info
        jars = [library_artifact(output, ctx.rule.kind) for output in java_outputs]
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 169, column 54, in library_artifact
        source_jars = [artifact_location(f) for f in src_jars],
Error: type 'depset' is not iterable
ERROR: /private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/rules_jvm_external~~maven~maven/BUILD:699:11: in @@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect aspect on jvm_import rule @@rules_jvm_external~~maven~maven//:org_opentest4j_opentest4j: 
Traceback (most recent call last):
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_bundled.bzl", line 67, column 37, in _aspect_impl
        return intellij_info_aspect_impl(target, ctx, semantics)
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 1144, column 32, in intellij_info_aspect_impl
        handled = collect_java_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 598, column 29, in collect_java_info
        jars = [library_artifact(output, ctx.rule.kind) for output in java_outputs]
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 169, column 54, in library_artifact
        source_jars = [artifact_location(f) for f in src_jars],
Error: type 'depset' is not iterable
ERROR: /private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/contrib_rules_jvm~/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/BUILD.bazel:86:13: in @@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect aspect on java_library rule @@contrib_rules_jvm~//java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5:system-exit-toggle: 
Traceback (most recent call last):
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_bundled.bzl", line 67, column 37, in _aspect_impl
        return intellij_info_aspect_impl(target, ctx, semantics)
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 1144, column 32, in intellij_info_aspect_impl
        handled = collect_java_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 598, column 29, in collect_java_info
        jars = [library_artifact(output, ctx.rule.kind) for output in java_outputs]
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 168, column 48, in library_artifact
        source_jar = artifact_location(src_jars[0]) if src_jars else None,
Error: type 'depset' has no operator [](int)
ERROR: /private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/contrib_rules_jvm~/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/BUILD.bazel:23:13: in @@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect aspect on java_library rule @@contrib_rules_jvm~//java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5:allow: 
Traceback (most recent call last):
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_bundled.bzl", line 67, column 37, in _aspect_impl
        return intellij_info_aspect_impl(target, ctx, semantics)
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 1144, column 32, in intellij_info_aspect_impl
        handled = collect_java_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 598, column 29, in collect_java_info
        jars = [library_artifact(output, ctx.rule.kind) for output in java_outputs]
    File "/private/var/tmp/_bazel_niklassemmler/70641108bc357a5c1cd378cfa96874dc/external/intellij_aspect/intellij_info_impl_bundled.bzl", line 168, column 48, in library_artifact
        source_jar = artifact_location(src_jars[0]) if src_jars else None,
Error: type 'depset' has no operator [](int)
WARNING: errors encountered while analyzing target '//:src/test/java/com/test/SomeTest', it will not be built.
Analysis of target '//:junit5-jupiter-starter-bazel' failed
WARNING: errors encountered while analyzing target '//:junit5-jupiter-starter-bazel', it will not be built.
Analysis of target '//:junit5-jupiter-starter-bazel' failed
WARNING: errors encountered while analyzing target '//:src/test/java/com/test/OtherTest', it will not be built.
Analysis of target '//:junit5-jupiter-starter-bazel' failed
INFO: Analyzed 4 targets (49 packages loaded, 1348 targets configured).
WARNING: errors encountered while analyzing target '//:Main', it will not be built.
Analysis of target '@@rules_jvm_external~~maven~maven//:org_apiguardian_apiguardian_api' failed
INFO: Found 4 targets...
ERROR: command succeeded, but not all targets were analyzed
INFO: Elapsed time: 0.364s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
FAILED: 
INFO: Build Event Protocol files produced successfully.
Build command finished. Retrieving BEP outputs...
tpasternak commented 4 months ago

Oh, could you please try with the newest intellij versions? We don't support the plugin for 2022.3, probably the one you have doesn't even support new bazel versions

niklassemmler commented 4 months ago

Thank you @tpasternak! I assumed Intellij would auto-update. Upgrading intellij fixed the issue.