Skip to content

Gradle plugin

Compile Java in an existing Gradle build with elide javac: the dev.elide plugins 1.2.0, runtime selection, persistent compilers and formatting tasks.

Read offlineelide help build-tools-gradle

On this page

The dev.elide.settings and dev.elide plugins make Gradle’s JavaCompile tasks run elide javac, and add formatting and dependency-export tasks. Gradle keeps dependency resolution, tests and packaging. This page covers plugin release 1.2.0.

Requirements

Version
Gradle 7.6.4 or later
JDK running Gradle 17 or later
Plugins 1.2.0, from Maven Central
Elide 1.5.1+20260903 or later

Release 1.2.0 is tested with Gradle 7.6.4, 8.14.5 and 9.7.1 on JDK 17, Gradle 8.14.5 on JDK 24 and Gradle 9.7.1 on JDK 26.

Install

The plugins are published to Maven Central. Add it to the plugin repositories in settings.gradle.kts, apply the settings plugin and select the Elide runtime for the whole build:

kotlin
pluginManagement {
    repositories {
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id("dev.elide.settings") version "1.2.0"
}

elide {
    runtime {
        mode = dev.elide.gradle.ElideRuntimeMode.MANAGED
        version = "1.6.3"
    }
}
utf-8 · kotlin · Lines: 17

The settings plugin also adds https://maven.elide.dev to the settings repositories, for the dev.elide and dev.elide.gradle groups only.

Each project that should compile with Elide applies dev.elide, with no version. Projects that do not apply it are untouched:

kotlin
// build.gradle.kts
plugins {
    id("dev.elide")
    java
}

elide {
    compiler = true
}
utf-8 · kotlin · Lines: 9

On Gradle 7.6, configure the settings extension with configure<dev.elide.gradle.ElideSettingsExtension> { runtime { … } }.

Runtime selection

mode Uses
AUTO (default) runtime.executable, then elide on PATH at version or newer, then managed
PATH runtime.executable, then elide on PATH at version or newer; never downloads
MANAGED Downloads and verifies version once, then reuses it offline

The PATH check runs elide --version and compares the semantic version, ignoring build metadata. Under AUTO an older elide is skipped with a log line; under PATH the build fails and names both versions. runtime.executable is a project setting and is never version-checked:

kotlin
// build.gradle.kts
elide {
    runtime {
        mode = dev.elide.gradle.ElideRuntimeMode.PATH
        executable = layout.projectDirectory.file("tools/elide")
    }
}
utf-8 · kotlin · Lines: 7

MANAGED downloads elide.<os>-<arch>.tgz (.zip on Windows) and its .sha256 from the Elide releases. A release version maps to its v tag (1.6.3 to v1.6.3); a nightly version (1.6.3+20261107) is its own tag. Assets exist for Linux amd64 and arm64, macOS arm64 and Windows amd64. The runtime is extracted to <GRADLE_USER_HOME>/caches/dev.elide/runtimes/<version>/<platform>/ and shared by every build on the machine.

Applying the plugin downloads and runs nothing; the runtime is probed or prepared when a task needs it. To build offline, prepare the managed runtime once while connected:

Terminal
bash
./gradlew prepareElideRuntime
./gradlew --offline build

Configuration

Settings elide { runtime { } } block, shared by every project that applies dev.elide:

Property Default Effect
mode AUTO Runtime selection mode
version 1.5.1+20260903 Managed version and minimum PATH version
versionFrom(catalog, alias) Reads version from a version catalog

version and versionFrom are exclusive. With versionFrom("libs", "elide"), declare elide under [versions] in gradle/libs.versions.toml.

Project elide { } block:

Property Default Effect
compiler true Compile JavaCompile tasks with elide javac
persistentCompiler false Keep up to four elide javac workers warm for the rest of the build
dependencyMode LEGACY GRADLE: Gradle owns resolution; install must stay off
install false Run elide install in the project directory before compiling
maven true With install, add .dev/dependencies/m2 as a Maven repository
manifest elide.pkl Manifest tracked as an elideInstall input
devRoot root .dev Directory holding dependencies/m2
runtime { } settings Per-project mode, version and executable

persistentCompiler, dependencyMode and manifest are Gradle properties; .set(…) works on every Gradle version:

kotlin
// build.gradle.kts
elide {
    dependencyMode.set(dev.elide.gradle.ElideDependencyMode.GRADLE)
    persistentCompiler.set(true)
}
utf-8 · kotlin · Lines: 5

The older names enableJavaCompiler, enableInstall, enableMavenIntegration, elideBin, runtimeMode, runtimeVersion and resolveElideFromPath still work but are deprecated.

Gradle properties override the block for a run, in both directions. Any value other than true reads as false:

Property Effect
elide.builder.javac.enable=false Compile with stock javac, without elideInstall or prepareElideRuntime
elide.builder.maven.install.enable=true Force elide install on; fails with dependencyMode GRADLE
Terminal
bash
./gradlew build -Pelide.builder.javac.enable=false

Tasks

Task Does
prepareElideRuntime Downloads and verifies the managed runtime; skipped for other runtimes
elideInstall Runs elide install; skipped unless install = true
elideJavaFormat Writes javaformat copies of .java files to build/elide/formatted/java/
elideKtfmt Writes ktfmt copies of .kt and .kts files to build/elide/formatted/kotlin/
elideCheckFormat Fails when files under src/ differ from those copies; changes nothing
elideFormat Applies those copies to src/
elideExportDependencies Runs elideExport<SourceSet>Dependencies for every source set
elideExport<SourceSet>Dependencies Writes build/elide/dependencies/<sourceSet>.tsv

Each dependency report line holds a coordinate, file name and SHA-256, from the source set’s runtime classpath. The formatting tasks are opt-in and never run during compilation. elideJavaFormat and elideKtfmt accept style options through arguments; see Formatting for the formatters themselves:

kotlin
// build.gradle.kts
tasks.named<dev.elide.gradle.ElideFormatTask>("elideKtfmt") {
    arguments.set(listOf("--kotlinlang-style"))
}
tasks.named("check") { dependsOn("elideCheckFormat") }
utf-8 · kotlin · Lines: 5

elideKtfmt accepts --meta-style, --google-style, --kotlinlang-style and --do-not-remove-unused-imports. elideJavaFormat accepts --aosp, --fix-imports-only, --skip-sorting-imports, --skip-removing-unused-imports, --skip-reflowing-long-strings and --skip-javadoc-formatting. Any other argument fails the task.

compileJava and compileTestJava keep their task types, so incremental compilation and the build cache work as usual. Cache keys include the Elide executable, the managed runtime version, the platform and the exact JDK build running Gradle.

Example

text
settings.gradle.kts
build.gradle.kts
src/main/java/com/example/HelloWorld.java
utf-8 · text · Lines: 3
kotlin
// build.gradle.kts
plugins {
    id("dev.elide")
    java
    application
}

application {
    mainClass = "com.example.HelloWorld"
}

repositories {
    mavenCentral()
}

elide {
    compiler = true
}

dependencies {
    implementation("com.google.guava:guava:33.4.8-jre")
}
utf-8 · kotlin · Lines: 22
java
// src/main/java/com/example/HelloWorld.java
package com.example;

import com.google.common.util.concurrent.SettableFuture;

public class HelloWorld {
    public static void main(String[] args) throws Exception {
        var greeting = SettableFuture.<String>create();
        greeting.set("Hello, World!");
        System.out.println(greeting.get());
    }
}
utf-8 · java · Lines: 12

With the settings.gradle.kts from Install:

Terminal
bash
./gradlew build
./gradlew -q run
Hello, World!

The first build downloads Elide in prepareElideRuntime; later builds, including --offline ones, reuse it.

OpenRewrite and dependency queries

For projects with an elide.pkl, see OpenRewrite and Dependency code index. The Gradle plugin does not add rewrite or code-index tasks; elideExportDependencies exports coordinates and checksums, but its output is not an input to elide index. See the project setup boundary before using these commands alongside Gradle.

Limits

  • Only Java compilation goes through Elide. Kotlin (compileKotlin) uses the Kotlin Gradle plugin’s compiler.
  • persistentCompiler does not support forkOptions.jvmArgs. Workers end with the build; each request times out after five minutes.
  • MANAGED is unavailable on Intel macOS; use PATH or runtime.executable there. Windows arm64 and other operating systems fail in every mode.
  • A managed runtime takes about 2.5 GB per version and platform. Extraction uses the JVM temporary directory; set TMPDIR if it is small.
  • With install = true, run ./gradlew elideInstall before build when dependencies exist only in .dev/dependencies/m2: Gradle can resolve them before any task runs.
  • The formatting tasks cover sources under src/ only.
  • Build cache entries are shared only between Gradle daemons on the same JDK build.

Was this page helpful?