# 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.

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

```bash
elide install
```

Maven is the default ecosystem. Buckets, repositories, credentials and install options:
[Dependencies](https://elide.help/docs/toolchain/dependencies).

## Projects with only a `pom.xml`

```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 run Maven goals, use [Native Maven](https://elide.help/docs/toolchain/jvm/native-maven).

## Inspect dependency code

In an `elide.pkl` project, the experimental [dependency code index](https://elide.help/docs/toolchain/jvm/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](https://elide.help/docs/toolchain/jvm/rewrite) 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" }
  }
}
```

- 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), and 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,
  "kotlinSymbolProcessing": false,
  "kotlinCompilerPlugins": false
}
```

| Field | Meaning |
| --- | --- |
| `javaAnnotationProcessing` | Java annotation processors 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](https://elide.help/docs/toolchain/jvm/kotlinc#choose-a-toolchain) are not affected. |

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