Skip to content

Maven plugin

Compile Java and Kotlin in an existing Maven build with Elide's javac and kotlinc: elide-maven-plugin 1.0.1, the Kotlin drop-in and the compilerId-only setup.

Read offlineelide help build-tools-maven

On this page

Adding dev.elide:elide-maven-plugin to a pom.xml makes the build compile Java with elide javac and Kotlin with elide kotlinc. Maven keeps dependency resolution, tests, packaging and every other plugin.

Requirements

Version
Maven 3.9.15 or later
JDK running Maven 11 or later
Elide 1.6 or later
Packaging jar, war, ejb or rar

Elide must be on PATH, or set <executable> (see Configuration). The packaging row applies to the lifecycle bindings that <extensions>true</extensions> installs.

Choose an artifact

Artifact Use when Compiles
elide-maven-plugin New setup, Java and Kotlin Java and Kotlin
elide-kotlin-maven-plugin The build already uses kotlin-maven-plugin Kotlin; Java through maven-compiler-plugin
elide-java-compiler Only Java, keeping maven-compiler-plugin as is Java

The current release is 1.0.1, groupId dev.elide, published to Maven Central. elide-maven-plugin depends on the other two and elide-kotlin-maven-plugin on elide-java-compiler.

Install

Maven resolves the plugin from Maven Central with no extra repository. Add it to the build:

xml
<build>
  <plugins>
    <plugin>
      <groupId>dev.elide</groupId>
      <artifactId>elide-maven-plugin</artifactId>
      <version>1.0.1</version>
      <extensions>true</extensions>
    </plugin>
  </plugins>
</build>
utf-8 · xml · Lines: 10

<extensions>true</extensions> is required: it replaces the default compile bindings. It also applies Kotlin’s smart defaults:

Default Applies when
src/main/kotlin, src/test/kotlin source roots The directory exists and no <sourceDirs> is set
kotlin-stdlib 2.3.21 dependency The POM declares no kotlin-stdlib

Set the property kotlin.smart.defaults.enabled to false (POM or -D) to turn both off.

To replace kotlin-maven-plugin in place, change its coordinates to dev.elide:elide-kotlin-maven-plugin:1.0.1 and keep its configuration and executions; the goals and parameters are the same. With extensions on, it binds Kotlin only; Java stays on maven-compiler-plugin 3.15.0 with javac unless you also add elide-java-compiler.

For Java only, without a new plugin:

xml
<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.15.0</version>
  <dependencies>
    <dependency>
      <groupId>dev.elide</groupId>
      <artifactId>elide-java-compiler</artifactId>
      <version>1.0.1</version>
    </dependency>
  </dependencies>
  <configuration>
    <compilerId>elide</compilerId>
  </configuration>
</plugin>
utf-8 · xml · Lines: 14

Goals

With extensions on, the goals bind to the lifecycle; nothing needs an <execution>.

Goal Phase Runs
elide:kapt process-sources Skipped unless annotation processors are configured
elide:compile-kotlin compile elide kotlinc on main sources
elide:compile compile elide javac on main sources, after Kotlin
elide:test-kapt process-test-sources Skipped unless annotation processors are configured
elide:test-compile-kotlin test-compile elide kotlinc on test sources
elide:test-compile test-compile elide javac on test sources

elide-kotlin-maven-plugin has the Kotlin goals under the prefix elide-kotlin, with the upstream names: kapt, compile, test-kapt and test-compile.

The extension also sets the other default bindings: maven-resources-plugin 3.5.0, maven-surefire-plugin 3.5.5, maven-install-plugin and maven-deploy-plugin 3.1.4, and the packaging plugin (maven-jar-plugin 3.5.0, maven-war-plugin 3.5.1, maven-ejb-plugin 3.3.0, maven-rar-plugin 3.5.0). Versions in the POM take precedence.

Each compile runs Elide as a child process:

Compiler Command
Java elide javac -- -version, then elide javac -- @<argfile>
Kotlin elide kotlinc -- <options> -- <source roots>

Configuration

The Java goals take every maven-compiler-plugin 3.14.0 parameter and the Kotlin goals every kotlin-maven-plugin 2.3.21 parameter (<release>, <compilerArgs>, <args>, <jvmTarget>, …); Elide receives them as compiler options. Every goal adds one parameter:

Parameter Default Effect
executable elide on PATH Path to the elide binary

executable has no user property; set it in <configuration>. On Windows the PATH lookup is for elide.exe.

xml
<plugin>
  <groupId>dev.elide</groupId>
  <artifactId>elide-maven-plugin</artifactId>
  <version>1.0.1</version>
  <extensions>true</extensions>
  <configuration>
    <executable>/opt/elide/bin/elide</executable>
  </configuration>
</plugin>
utf-8 · xml · Lines: 9

With elide-java-compiler, set <executable> in the maven-compiler-plugin configuration instead (or -Dmaven.compiler.executable).

Some inherited parameters are fixed or unused:

Parameter Goals Behavior
compilerId Java Always elide
fork Java Always on
useDaemon, kotlinDaemonJvmArgs Kotlin No effect
daemonShutdownDelayMs Kotlin No effect
myIncremental, incrementalCachesRoot Kotlin No effect
annotationProcessors, annotationProcessorPaths kapt Both empty: goal skipped

Example

A project with a Kotlin object, a Java main class and a JUnit test:

text
pom.xml
src/main/kotlin/com/example/Greeter.kt
src/main/java/com/example/Hello.java
src/test/java/com/example/GreeterTest.java
utf-8 · text · Lines: 4
xml
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>hello</artifactId>
  <version>1.0.0</version>

  <properties>
    <maven.compiler.release>21</maven.compiler.release>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>5.13.4</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>dev.elide</groupId>
        <artifactId>elide-maven-plugin</artifactId>
        <version>1.0.1</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
</project>
utf-8 · xml · Lines: 30
Terminal
bash
mvn package
[INFO] Added kotlin-stdlib dependency, version 2.3.21
[INFO] --- elide:1.0.1:kapt (default-kapt) @ hello ---
[INFO] No annotation processors configured, skipping kapt
[INFO] --- elide:1.0.1:compile-kotlin (default-compile-kotlin) @ hello ---
[INFO] ✅  Kotlin sources compiled to `classes` (1.3s)
[INFO] --- elide:1.0.1:compile (default-compile) @ hello ---
[INFO] Compiling 1 source file with elide [forked debug release 21] to target/classes
[INFO] --- elide:1.0.1:test-compile (default-test-compile) @ hello ---
[INFO] Compiling 1 source file with elide [forked debug release 21] to target/test-classes
[INFO] --- surefire:3.5.5:test (default-test) @ hello ---
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] --- jar:3.5.0:jar (default-jar) @ hello ---
[INFO] Building jar: target/hello-1.0.0.jar
[INFO] BUILD SUCCESS

OpenRewrite and dependency queries

For projects with an elide.pkl, see OpenRewrite and Dependency code index. The compiler plugin does not add rewrite or code-index goals or pass Maven’s resolved dependency graph to those commands. See the project setup boundary before using them alongside Maven.

Limits

  • kapt does not run: a kapt execution with annotation processors configured fails.
  • Kotlin compiler plugins (<compilerPlugins>) other than all-open, no-arg, sam-with-receiver, assignment and Lombok fail with a compiler error.
  • The added kotlin-stdlib is version 2.3.21; declare kotlin-stdlib yourself to pick another.
  • Kotlin output reaches Maven as plain log lines (all INFO on success, all ERROR on failure), without per-file diagnostics.
  • Each compile runs a new elide process (two for Java); there is no shared compiler daemon between modules.
  • Packagings other than jar, war, ejb and rar get no Elide bindings from the extension.

To leave Maven, see Adopt an existing project.

Was this page helpful?