bazel-eclipse icon indicating copy to clipboard operation
bazel-eclipse copied to clipboard

RFC: Support multiple classpaths within a Java Eclipse project

Open plaird opened this issue 6 years ago • 1 comments

As a BEF user with a Bazel package with multiple Java targets I would like the classpath provided to JDT to be accurate Such that import statements will fail if the BUILD target does not have the dependency

Example Create two java_library targets in a BUILD file. In LibA, make a dependency on some open source library. In LibB, do not have that dep listed. In a Java file that is brought into LibB, use the API for the open source library. JDT will not complain. The command line build and Eclipse Problems View will show the error though.

Background: Right now the classpath computed for the Eclipse Java project by the Bazel Classpath Container is the union of all Java targets in the BUILD file. This can lead to issues where JDT will be happy, but the command line build (and Eclipse problems view) will have errors. JDT (seems like) supports only a single classpath for an Eclipse Java project (with two divisions - main and test).

Possible outcomes of this ticket:

  • Discover that supporting multiple classpaths in a single Eclipse Java project is already possible, implement it, and celebrate
  • Discover that JDT would only need a few minor changes to support this, file those with the JDT team, and hope for resolution
  • Conclude that this will never be possible, and write up a one-pager about it in the docs

plaird avatar Dec 02 '19 20:12 plaird

The IJ plugin devs have so far punted on the IDE project -> Bazel target -> classpath mapping problem. They have a single classpath for the entire workspace. https://github.com/bazelbuild/intellij/issues/179

But that issue has some relevant discussions/feedback about the concepts underlying this feature.

Given the limited time we have to spend on BEF, cracking open JDT and making mods in it is not something that is pragmatic to consider. That project has a very long history, and I am sure is resistant to change given how many users (millions?) depend on it working without regressions.

plaird avatar Dec 05 '19 19:12 plaird