salesforce / bazel-jdt-java-toolchain

Eclipse Java Compiler (ECJ) for Bazel
Apache License 2.0
9 stars 6 forks source link

Compile error with rules_jvm_external #28

Open peakschris opened 2 months ago

peakschris commented 2 months ago

I am trying this toolchain in our bazel 7.2.1 project. We use modules and rules_jvm_external. I fixed one small issue with windows, and then am seeing this problem:

Is there a way to resolve this? or a way to use JDT conditionally only for our own code?

Do you still recommend use of JDT in bazel7/modules world?

I can contribute fixes if I can get some guidance as to where the issue is.

D:\workdir\javaproject2>bazel build //... --verbose_failures
INFO: Analyzed 12 targets (0 packages loaded, 0 targets configured).
ERROR: D:/udu/b/xipfius7/external/rules_jvm_external~/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/BUILD:3:12: Building external/rules_jvm_external~/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry.jar (1 source file) [for tool] failed: (Exit 1): java.exe failed: error executing Javac command (from target @@rules_jvm_external~//private/tools/java/com/github/bazelbuild/rules_jvm_external/jar:AddJarManifestEntry)
  cd /d D:/udu/b/xipfius7/execroot/_main
  SET LC_CTYPE=en_US.UTF-8
    SET PATH=<redacted>
  external\rules_java~~toolchains~remotejdk21_win\bin\java.exe --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.resources=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED -Dsun.io.useCanonCaches=false -XX:-CompactStrings -Xlog:disable -Xlog:all=warning:stderr:uptime,level,tags -XX:-MaxFDLimit -jar external/bazel_jdt_java_toolchain/compiler/export/JdtJavaBuilder_deploy.jar @bazel-out/x64_windows-opt-exec-ST-d57f47055a04/bin/external/rules_jvm_external~/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry.jar-0.params @bazel-out/x64_windows-opt-exec-ST-d57f47055a04/bin/external/rules_jvm_external~/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry.jar-1.params
# Configuration: db806cde30d1954eb42b8b71bb10bbf7e2f4f7575e90723f381588aac94e2bae
# Execution platform: @@platforms//host:host
----------
1. ERROR in D:\udu\b\xipfius7\execroot\_main\external\rules_jvm_external~\private\tools\java\com\github\bazelbuild\rules_jvm_external\jar\AddJarManifestEntry.java (at line 6)
        import com.github.bazelbuild.rules_jvm_external.ByteStreams;
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import com.github.bazelbuild.rules_jvm_external.ByteStreams cannot be resolved
----------
2. ERROR in D:\udu\b\xipfius7\execroot\_main\external\rules_jvm_external~\private\tools\java\com\github\bazelbuild\rules_jvm_external\jar\AddJarManifestEntry.java (at line 7)
        import com.github.bazelbuild.rules_jvm_external.zip.StableZipEntry;
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import com.github.bazelbuild.rules_jvm_external.zip cannot be resolved
----------
3. ERROR in D:\udu\b\xipfius7\execroot\_main\external\rules_jvm_external~\private\tools\java\com\github\bazelbuild\rules_jvm_external\jar\AddJarManifestEntry.java (at line 191)
        ZipEntry newManifestEntry = new StableZipEntry(JarFile.MANIFEST_NAME);
                                        ^^^^^^^^^^^^^^
StableZipEntry cannot be resolved to a type
----------
4. ERROR in D:\udu\b\xipfius7\execroot\_main\external\rules_jvm_external~\private\tools\java\com\github\bazelbuild\rules_jvm_external\jar\AddJarManifestEntry.java (at line 211)
        ByteStreams.copy(in, zos);
        ^^^^^^^^^^^
ByteStreams cannot be resolved
----------
4 problems (4 errors)
guw commented 2 months ago

I haven't tried with this project. But it looks like the list of dependencies is not correct. Is there a PR/branch to play with?

peakschris commented 2 months ago

Hi there, thanks for the reply,

Here is a reproducer: https://github.com/peakschris/jdt-compiler-issue

It references a fork of this repo with one small fix for windows: https://github.com/salesforce/bazel-jdt-java-toolchain/pull/29