salesforce/bazel-vscode-java

failure with `Unresolved requirement: Import-Package: com.google.common.cache; version="[32.1.0,33.0.0)"`

toumorokoshi opened this issue · 3 comments

Hello! I'm trying to use the extension to develop bazel itself. I:

  1. updated my JDK to 22
  2. cloned the bazel project
  3. opened vscode with the bazel-vscode-java extension enabled (along with the standard java extension owned by Microsoft).

And I have the following error:

Apr 16, 2024 8:22:16 AM org.apache.aries.spifly.BaseActivator log
INFO: Registered provider ch.qos.logback.classic.servlet.LogbackServletContainerInitializer of service jakarta.servlet.ServletContainerInitializer in bundle ch.qos.logback.classic
Apr 16, 2024 8:22:16 AM org.apache.aries.spifly.BaseActivator log
INFO: Registered provider ch.qos.logback.classic.spi.LogbackServiceProvider of service org.slf4j.spi.SLF4JServiceProvider in bundle ch.qos.logback.classic
[Error - 8:22:22 AM] Apr 16, 2024, 8:22:17 AM FrameworkEvent ERROR
org.osgi.framework.BundleException: Could not resolve module: com.salesforce.bazel.sdk [123]
  Unresolved requirement: Require-Bundle: com.salesforce.bazel.importedsource; bundle-version="2.0.0"
    -> Bundle-SymbolicName: com.salesforce.bazel.importedsource; bundle-version="2.0.0.v20240203-1430"
       com.salesforce.bazel.importedsource [122]
         Unresolved requirement: Import-Package: com.google.auto.value; resolution:="optional"
         Unresolved requirement: Import-Package: com.google.errorprone.annotations; resolution:="optional"
         Unresolved requirement: Import-Package: com.github.benmanes.caffeine.guava; version="3.1.8"
           -> Export-Package: com.github.benmanes.caffeine.guava; bundle-symbolic-name="com.github.ben-manes.caffeine.guava"; bundle-version="3.1.8"; version="3.1.8"; uses:="com.github.benmanes.caffeine.cache,com.google.common.cache"
              com.github.ben-manes.caffeine.guava [117]
                Unresolved requirement: Import-Package: com.google.common.cache; version="[32.1.0,33.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:493)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:2073)
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:143)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:2064)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:2004)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1967)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1883)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:341

Any pointers on where to look?

guw commented

@toumorokoshi Can you try the latest pre-release version please?

The pre-release version fixed the issue partly! thank you.

The next issue is that there are still packages that cannot be resolve - but it brought the errors down from 10k to 2k:

20240416_13h31m54s_grim

with imports failing like com.google.common.collect.ImmutableList, which seems to come from com.google:guava: https://github.com/google/guava/blob/master/guava/src/com/google/common/collect/ImmutableList.java.

it looks like the file should find the dep ok too (likely aliased as //third_party: https://github.com/bazelbuild/bazel/blob/master/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/BUILD#L68.

guw commented

Closing this as a dup of #109. I published a new release to the marketplace yesterday.

The error you are seeing is related to lack of support of how the Bazel project itself imports jars. I have not had time to look into it in more details. Rules JVM External should be supported, though.