Skip to content

Maven dependencies

Install Maven dependencies with elide install, including for projects that have only a pom.xml, and configure annotation processors in an Elide project.

Read offlineelide help tooling-jvm-maven

On this page

Elide resolves Maven dependencies declared in elide.pkl or a pom.xml.

Terminal
bash
elide install

Maven is the default ecosystem. Buckets, repositories, credentials and install options: Dependencies.

Kotlin Multiplatform libraries

Kotlin Multiplatform libraries such as com.squareup.okhttp3:okhttp 5, io.ktor:ktor-client-core and org.jetbrains.kotlinx:kotlinx-coroutines-core publish their JVM classes in a separate module, such as okhttp-jvm. Declare the library itself:

pkl
dependencies {
  maven {
    packages { "com.squareup.okhttp3:okhttp:5.1.0" }
  }
}
utf-8 · pkl · Lines: 5

When a library’s POM announces Gradle Module Metadata, elide install installs the JVM module the metadata names, with its dependencies, and the declared coordinate resolves to it on every classpath. The metadata comes from the repository that served the POM. Libraries that publish their classes under their own coordinate, and POMs that announce no metadata, are unchanged and cost no extra request.

Metadata that cannot be read, or that names more than one JVM module, fails the install, and so does metadata a POM announces that an offline install has not downloaded before.

To read every library from its POM alone, set gradleMetadata = false:

pkl
dependencies {
  maven {
    gradleMetadata = false
  }
}
utf-8 · pkl · Lines: 5

In a workspace, the root’s gradleMetadata = false applies to every member. Without it, elide build deps --no-gradle-module-metadata turns redirects off for one build, and ELIDE_GRADLE_MODULE_METADATA=0 does so for elide install; an explicit --gradle-module-metadata outranks the variable. Neither turns redirects on when the manifest turns them off. Changing any of these resolves the graph again.

A graph resolved by an earlier Elide keeps the library’s own coordinate until the dependency list changes. Run elide install --fresh once to install the JVM modules.

Projects with only a pom.xml

Terminal
bash
elide install -p .

Elide reads the POM’s direct dependencies, ${property} values and its own dependencyManagement. Parents and imported BOMs are not merged; a dependency versioned only by a parent is dropped.

POM scope Bucket
compile packages
provided, system compileOnly
runtime runtimeOnly
test testPackages

To build it with Maven and Elide’s compilers, use the Maven plugin.

Inspect dependency code

In an elide.pkl project, the experimental dependency code index records types, members, and references from resolved Maven JARs. Use elide index resolve to find a class’s defining artifact, or elide index references to inspect what a dependency class uses.

OpenRewrite uses that index to run Java recipes. Declare additional recipe modules under dependencies.maven.devPackages and preview source changes with --dry-run.

Annotation processors

pkl
dependencies {
  maven {
    packages { "org.mapstruct:mapstruct:1.6.3" }
    processors { "org.mapstruct:mapstruct-processor:1.6.3" }
  }
}
utf-8 · pkl · Lines: 6
  • Processors run in elide build and elide javac, on main and test source sets.
  • A changed processor JAR recompiles.
  • Generated sources go to .dev/jvm/generated-sources/<set>/java and compile with the set.
  • Processors see Java sources only, never Kotlin declarations. Kotlin compiles before Java processing, so Kotlin code that uses generated types must get them from an upstream source set or project.
  • Project builds don’t run processors over Kotlin (KAPT), except Android projects with processors declared; KSP is unsupported.
  • -proc:none, -proc:only and -proc:full behave as in javac.

elide javac --capabilities reports what this Elide build supports:

json
{
  "version": 1,
  "javaAnnotationProcessing": true,
  "javacPlugins": true,
  "kotlinSymbolProcessing": false,
  "kotlinCompilerPlugins": false
}
utf-8 · json · Lines: 7
Field Meaning
javaAnnotationProcessing Java annotation processors run.
javacPlugins javac -Xplugin plugins such as Error Prone and NullAway run.
kotlinSymbolProcessing KSP processors run.
kotlinCompilerPlugins Third-party Kotlin compiler plugins run in the embedded compiler. Built-in plugins and a managed or custom toolchain are not affected.

Set ELIDE_TRACE_PROCESSORS=1 to print each processor class as it loads (Loading processor dependency: demo.HelloProcessor).

Was this page helpful?