Bazel rules for Elide — Kotlin / Java compilation, JUnit Platform tests, code formatting, and native-image builds powered by the Elide runtime.
Status: pre-alpha. Public API is unstable. Pin a specific commit or wait for the first tagged release.
Elide consolidates a polyglot runtime, a Kotlin/Java toolchain, formatters (google-java-format, ktfmt), and ahead-of-time native-image into one binary. For Bazel monorepos this means:
- One hermetic toolchain instead of separate
rules_java,rules_kotlin, andrules_graalvmtoolchains, each with their own JDK pin. - Native-image and formatters as first-class rules, not separate rulesets.
- One small set of rules to learn (
elide_kotlin_library,elide_java_library,elide_native_image,elide_format, ...) instead of three overlapping ecosystems.
MODULE.bazel:
bazel_dep(name = "rules_elide", version = "0.0.0")
elide = use_extension("@rules_elide//elide:extensions.bzl", "elide")
elide.install(version = "latest", channel = "nightly")
use_repo(elide, "elide_toolchains")
register_toolchains("@elide_toolchains//:all")BUILD.bazel:
load("@rules_elide//elide:defs.bzl", "elide_kotlin_binary", "elide_kotlin_library")
elide_kotlin_library(
name = "lib",
srcs = glob(["src/main/kotlin/**/*.kt"]),
)
elide_kotlin_binary(
name = "app",
srcs = ["Main.kt"],
main_class = "MainKt",
deps = [":lib"],
)bazel run //:app| Rule | Purpose | Reference |
|---|---|---|
elide_java_library |
Compile .java sources into a JavaInfo-bearing jar (via elide javac --jar) |
docs/java.md |
elide_java_binary |
_library + launcher (elide java) |
docs/java.md |
elide_java_test |
_library + JUnit Platform launcher |
docs/java.md |
elide_kotlin_library |
Compile mixed .kt / .java sources (via elide kotlinc) |
docs/kotlin.md |
elide_kotlin_binary |
_library + launcher |
docs/kotlin.md |
elide_kotlin_test |
_library + JUnit Platform launcher |
docs/kotlin.md |
elide_native_image |
Native AOT binary from JavaInfo deps (via elide native-image) |
docs/native_image.md |
elide_format |
In-place format .java (google-java-format) or .kt (ktfmt) |
docs/format.md |
elide_toolchain |
Wrap an elide binary as a Bazel toolchain | docs/toolchain.md |
Providers: ElideToolchainInfo, ElideInfo (docs/providers.md).
Top-level entry point: @rules_elide//elide:defs.bzl.
The elide module extension downloads the elide release artifact for the
host platform from the public Elide CDN:
https://elide.zip/artifacts/{channel}/{version}/elide.{os}-{cpu}.{ext}
Each artifact is verified against an in-tree SRI integrity table.
- channel:
nightly,preview, orrelease. Pre-alpha: onlynightlyandprevieware populated upstream. - version: any concrete revision (e.g.
1.2.0-beta) or the rolling pointerlatest. Withlatest, integrity reflects the snapshot captured inelide/private/versions.bzl; if the CDN advances, regenerate the integrity row.
Supported platforms:
| OS | CPU | Constraint |
|---|---|---|
| Linux | amd64 | @platforms//os:linux + @platforms//cpu:x86_64 |
| Linux | arm64 | @platforms//os:linux + @platforms//cpu:aarch64 |
| macOS | arm64 | @platforms//os:macos + @platforms//cpu:aarch64 |
Windows is published on the CDN but not yet supported by these rules — the
launcher templates are POSIX sh only. See Roadmap below.
MODULE.bazel.lock records the resolved hashes (the extension marks itself
reproducible = True).
Every compile rule returns a complete JavaInfo:
output_jar— the full class JAR produced byelide javac --jar/elide kotlinc -d.compile_jar— ABI jar derived viajava_common.run_ijarfor fast downstream incremental rebuilds.source_jars— sources packaged viajava_common.pack_sources(IDE sync / Maven publish friendly).
elide_java_test and elide_kotlin_test launch the JUnit Platform
ConsoleLauncher. The launcher honours Bazel's test runner contract:
TEST_TMPDIR, XML_OUTPUT_FILE, and TEST_FILTER. Reports written to
$TEST_TMPDIR/reports/ are merged into $XML_OUTPUT_FILE post-run.
Consumer requirement: place
org.junit.platform:junit-platform-console-standalone on the test
classpath via runtime_deps (typically through rules_jvm_external).
Use test_class = "<fqcn>" to select a single class; leave empty to scan
the classpath.
load("@rules_elide//elide:defs.bzl", "elide_format")
elide_format(
name = "format",
srcs = glob(["src/**/*.kt"]) + glob(["src/**/*.java"]),
)bazel run //:format formats files in place. Java sources route through
google-java-format; .kt/.kts route through ktfmt. A single target may
not mix languages — split into two elide_format targets if needed.
- No host JDK detection. No
repository_ctx.which. The full extracted elide distribution is declared as runfiles of the toolchain. - Platform-resolved via
@platforms//os:*+@platforms//cpu:*. - All file paths are relative; no developer-machine paths leak into outputs. Should run unchanged under Buildfarm, BuildBuddy RBE, or EngFlow remote execution.
| If you currently use… | Migrate to rules_elide for… |
|---|---|
rules_java |
Faster compile in steady state (~2.8x on micro-bench), JUnit 5 native, ABI ijar + source jars |
rules_kotlin |
Faster compile (~5.5x on micro-bench), compile-time-compatible JavaInfo, single Elide JDK |
rules_graalvm |
Native-image without a separate toolchain or GraalVM SDK download |
rules_elide returns JavaInfo from every compile rule, so existing
java_library / kt_jvm_library consumers can depend on elide_* targets
unchanged.
See benchmarks/RESULTS.md for methodology, recorded
numbers, and how to reproduce locally via ./benchmarks/bench.sh.
To validate the smoke workspace against a locally-built elide binary,
point ELIDE_DEV_BIN at the binary and enable --config=dev in
e2e/smoke/:
ELIDE_DEV_BIN=/abs/path/to/elide bazel build //... --config=dev
ELIDE_DEV_BIN=/abs/path/to/elide bazel test //... --config=devSee e2e/smoke/README.md for the full flow.
| Item | Status |
|---|---|
| Persistent worker protocol | Pending Elide CLI WorkRequest/WorkResponse support |
elide native-image under Bazel |
Blocked on upstream Elide CLI JavaCommand NPE under sandbox env |
Kotlin srcjars (extract+compile) |
Pending |
Stable release channel populated |
Pending upstream |
| BCR (Bazel Central Registry) | Templates in .bcr/; first publication after release |
| Layer | Status |
|---|---|
| Bazel | 7.4.0+ (Bzlmod-only; legacy WORKSPACE is not supported) |
Semantic versioning. compatibility_level = 1 until a hard API break.
Apache 2.0. See LICENSE.
See CONTRIBUTING.md.