Перейти к содержимому

Эта страница ещё не переведена и показана на английском.

Elide for Kotlin users

Switching from kotlinc and Gradle to Elide: running Kotlin files directly, what changes in builds, dependencies and tests, benchmarks and trade-offs.

На этой странице
Open in ChatGPTOpen in Claude

Elide bundles Kotlin 2.5.0-Beta1 and JDK 25 with a build tool, Maven dependency resolver, JUnit runner and ktfmt.

Run the same code

A file with a main function compiles and runs directly:

elide run Main.kt

elide kotlinc, elide java and elide jar run the Kotlin and JDK tools. Their arguments go after --:

elide kotlinc -- -version
elide kotlinc -- -d out Main.kt

A project is an elide.pkl file. Maven dependencies, kotlinx.serialization, kotlinx.coroutines and JUnit need no plugin blocks:

elide init --plain --skip-defaults --template ktjvm   # new project
elide install                                         # resolve Maven dependencies
elide build                                           # compile and assemble
elide test                                            # run JUnit tests
elide run                                             # run jvm.main
elide format -- src                                   # ktfmt

See Java and Kotlin with Elide, Kotlin Compiler, Testing and the elide.pkl reference.

What changes

With kotlinc and GradleWith Elide
Install a JDK and kotlincNothing; both are bundled.
kotlinc Main.kt -d outelide kotlinc -- -d out Main.kt
build.gradle.ktselide.pkl
kotlin("jvm") version "2.3.0"kotlin { toolchain = new Kotlin.ManagedKotlinToolchain { version = "2.3.0" } }
kotlin("plugin.serialization")On by default (kotlin.features).
Subprojects in settings.gradle.ktsworkspace { members { "core"; "app" } } in the root elide.pkl
./gradlew build, test, runelide build, elide test, elide run
Migrate a ./gradlew buildelide adopt; see Adopt an Existing Project.
ktfmtelide format
IDE project importelide project export --format=intellij
kapt, kspNo equivalent.

ManagedKotlinToolchain needs import "elide:Kotlin.pkl" as Kotlin and applies to project builds; elide kotlinc always uses the bundled Kotlin.

Benchmarks

No benchmarks are published for JVM programs in 1.6.0. For ahead-of-time builds, see Native Image.

Strengths

  • One binary replaces the JDK, kotlinc, the Maven resolver, the JUnit launcher and ktfmt.
  • kotlinx.serialization, coroutines, Power Assert and Metro are enabled without configuration. atomicfu is on too, with its runtime library.
  • ManagedKotlinToolchain builds a project with another Kotlin version, prereleases included.
  • Workspace members can read a sibling’s internal declarations with project("core").friend().

Weaknesses

  • No Gradle support: elide build does not read build.gradle.kts, and Gradle plugins have no equivalent.
  • KAPT and KSP are unsupported; Kotlin that uses Java-generated types must take them from an upstream source set.
  • The bundled compiler is Kotlin 2.5.0-Beta1, a beta.
  • elide java does not add kotlin-stdlib (NoClassDefFoundError), and elide kotlinc -- -include-runtime fails. Run with elide run, or package with a Jvm.JvmApplication (JAR Assembly).
  • elide adopt is untested on multi-module and Android projects.

Next steps

Была ли эта страница полезной?