bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://github.com/bazelbuild/intellij/blob/master/docs/index.md
Apache License 2.0
764 stars 308 forks source link

AutoValue/AutoFactory generated code not indexed by Intellij when syncing Kotlin libraries #6657

Open ianb-pomelo opened 3 months ago

ianb-pomelo commented 3 months ago

Description of the bug:

We have imported the AutoValue and AutoFactory plugins into our Kotlin Bazel workspace and it build and generates things as expected. However, Intellij is not indexing the generated classes and thus they appear unresolved. I have checked the build output and the classes are in the lib.jar and the lib-java.jar but not in the lib-kt.jar.

Which category does this issue belong to?

Intellij

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

Import this repo and try to sync. The sync succeeds but TestFileFactory is unresolved.

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

IntelliJ IDEA 2024.2.0.2 Build #IU-242.20224.419

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

Kotlin 1.7

What Bazel plugin version are you using?

2024.07.30.0.2-api-version-242

Have you found anything relevant by searching the web?

This has been occurring for a long time so not a regression. We've been able to write out own KAPT plugins that generate code and Intellij indexes those so as far as I can tell it is just these Auto* plugins

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

No response

agluszak commented 1 month ago

Are you sure that your repro is correct? For me your code does not compile

andrzej.gluszak@pl-unit-004 ~/c/i/intellij-sync-issue (main)> bazel build //...
INFO: Analyzed 2 targets (2 packages loaded, 7 targets configured).
INFO: From Building external/rules_jvm_external/private/tools/java/com/github/bazelbuild/rules_jvm_external/zip/libzip.jar (1 source file) [for tool]:
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
INFO: From Building external/rules_jvm_external/private/tools/java/com/github/bazelbuild/rules_jvm_external/librules_jvm_external.jar (4 source files) [for tool]:
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
INFO: From Building external/rules_jvm_external/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry.jar (1 source file) [for tool]:
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
ERROR: /home/andrzej.gluszak/code/ij_repros/intellij-sync-issue/BUILD:14:15: Building test-java.jar (1 source jar) and running annotation processors (AutoFactoryProcessor) failed: (Exit 1): java failed: error executing Javac command (from target //:test) external/rules_java~~toolchains~remotejdk21_linux/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' ... (remaining 19 arguments skipped)
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
bazel-out/k8-fastbuild/bin/_javac/test/test-java_tmp/TestFileFactory.java:2: error: package javax.inject does not exist
import javax.inject.Inject;
                   ^
bazel-out/k8-fastbuild/bin/_javac/test/test-java_tmp/TestFileFactory.java:9: error: cannot find symbol
  @Inject
   ^
  symbol:   class Inject
  location: class TestFileFactory
Target //:test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.423s, Critical Path: 1.10s
INFO: 13 processes: 5 internal, 3 linux-sandbox, 5 worker.
ERROR: Build did NOT complete successfully
andrzej.gluszak@pl-unit-004 ~/c/i/intellij-sync-issue (main) [1]> bazel --version
bazel 7.3.2
ianb-pomelo commented 1 month ago

Ah yea thanks, missing a dependency. I've pushed a fix that builds successfully for me