Skip to content

Conversation

@blorente
Copy link
Contributor

@blorente blorente commented Jul 23, 2025

Thus allowing it to be "statically linkable".

The user-facing UX has two options:

  • To use the command line, like this: bazel build //:<your-gazelle> '--@contrib_rules_jvm//java/gazelle:embed_server=True'
  • To create a transition, like the one we use for testing in java/gazelle/testdata/gazelle_build_mode.bzl.

Caveats and implementation notes:

  • We always need a java binary at runtime. This can be specified via JAVA_HOME, or a new environment variable, GAZELLE_JAVA_BIN. We don't strictly need the new env var, we should be able to always use JAVA_HOME, but I thought it would be nice to have a variable explicitly for the Java plugin, just in case it differs from your runtime environment.
  • We implement the embedding directly in servermanager.go, by conditionally compiling one of two versions of the library.
  • We need to do some hacks for testing, because we need to wrap the actual gazelle binary, and the tests do not run the gazelle binary from Bazel's sandboxed working directory.
  • When running the embedded server, we materialize the javaparser server jar 100% of the time. We could be smarter about this, but the server is small enough that I don't think it matters.

@blorente blorente force-pushed the blorente/318/embedded-server branch 6 times, most recently from 0224679 to 526e7d8 Compare July 24, 2025 09:51
Copy link
Collaborator

@stevebarrau stevebarrau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach look reasonable.

Code level comments only.

@blorente blorente force-pushed the blorente/318/embedded-server branch 2 times, most recently from f09a83c to f5cb4a9 Compare July 25, 2025 10:36
@blorente blorente force-pushed the blorente/318/embedded-server branch 2 times, most recently from 617b0b0 to 9fcff43 Compare July 25, 2025 12:56
@blorente blorente force-pushed the blorente/318/embedded-server branch from 9fcff43 to da0a8d1 Compare July 31, 2025 09:10
@blorente blorente requested review from shs96c and stevebarrau July 31, 2025 09:37
@blorente blorente marked this pull request as ready for review September 2, 2025 07:34
Copy link
Collaborator

@shs96c shs96c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shs96c shs96c merged commit 639446e into bazel-contrib:main Sep 8, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants