Skip to content

Gradle plugin

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

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.

Requirements

Version
Gradle7.6.4 or later
JDK running Gradle17 or later
Plugins1.2.0, from Maven Central
Elide1.6

Install

settings.gradle.kts adds Maven Central to the plugin repositories and selects the Elide runtime for the whole build:

import dev.elide.gradle.ElideRuntimeMode

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

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

elide {
    runtime {
        mode = ElideRuntimeMode.MANAGED
        version = "1.6.0"
    }
}

Each project that should compile with Elide applies dev.elide, with no version:

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

elide {
    compiler = true
}

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

Runtime selection

modeUses
AUTO (default)runtime.executable if set, then elide on PATH if it reports at least version, then the managed runtime
PATHelide on PATH; fails if it is older than version
MANAGEDDownloads version once into <GRADLE_USER_HOME>/caches/dev.elide/runtimes/, verifies its SHA-256, reuses it offline
elide {
    runtime {
        mode = ElideRuntimeMode.PATH
        executable = layout.projectDirectory.file("tools/elide")
    }
}

Managed downloads cover Linux x86_64 and arm64, macOS arm64 and Windows x86_64. Applying the plugin downloads and runs nothing; the runtime is prepared when a task needs it.

Configuration

Project elide { } block:

PropertyDefaultEffect
compilertrueCompile JavaCompile tasks with elide javac
persistentCompilerfalseKeep up to four elide javac workers warm for the rest of the build
dependencyModeLEGACYGRADLE: Gradle owns resolution; install must stay off
installfalseRun elide install from elide.pkl before compiling
maventrueWith install, add .dev/dependencies/m2 as a Maven repository
manifestelide.pklManifest install reads

Gradle properties override the block for a run, in both directions:

PropertyEffect
elide.builder.javac.enable=falseCompile with stock javac
elide.builder.maven.install.enable=trueForce elide install on
./gradlew build -Pelide.builder.javac.enable=false

Tasks

TaskDoes
prepareElideRuntimeDownloads and verifies the managed runtime
elideInstallRuns elide install; skipped unless install = true
elideCheckFormatFails when .java, .kt or .kts files under src/ need formatting; changes nothing
elideFormatFormats them in place
elideExportDependenciesWrites resolved coordinates and SHA-256 per source set to build/elide/dependencies/

compileJava and compileTestJava keep their task types, so incremental compilation and the build cache work as usual.

Example

settings.gradle.kts
build.gradle.kts
src/main/java/com/example/HelloWorld.java
src/test/java/com/example/HelloWorldTest.java
// 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")
    testImplementation("org.junit.jupiter:junit-jupiter:5.13.4")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

tasks.test {
    useJUnitPlatform()
}

With the settings.gradle.kts from Install:

./gradlew clean build run
> Task :prepareElideRuntime UP-TO-DATE
> Task :elideInstall SKIPPED
> Task :clean
> Task :compileJava
> Task :jar
> Task :run
Hello, World!
> Task :compileTestJava
> Task :test
> Task :build
BUILD SUCCESSFUL in 5s
Configuration cache entry stored.

The first run downloads Elide in prepareElideRuntime; later runs 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.
  • MANAGED is unavailable on Intel macOS; use PATH there.
  • elideFormat covers sources under src/ only.

Was this page helpful?