DependencyResolutionStage

open class DependencyResolutionStage(aetherContext: AetherContext, logger: RunnerLogger)(source)

Stage 2 of the LST classpath-resolution pipeline: invoke the project's build tool as a subprocess to obtain a fully-resolved dependency list, then download any missing JARs via Maven Resolver (Eclipse Aether).

Why Stage 2? Stage 1 (ProjectBuildStage) extracts the exact on-disk classpath but requires the project to be fully buildable. Stage 2 runs lighter subprocess commands (mvn dependency:tree / gradle dependencies) that work even when the project cannot be compiled — for example when compiler plugins are missing or the source contains errors.

Maven projects: Runs mvnw dependency:tree (or mvn when no wrapper is present). The tree output is parsed to extract group:artifact:version coordinates. Resolved artifacts are fetched directly (no POM traversal needed because Maven has already computed the transitive closure).

Gradle projects: Runs gradle dependencies for the root project and all declared subprojects. Parsed coordinates are resolved directly via Aether. Unlike Stage 1, this does not require the project to compile successfully.

Mixed Maven+Gradle projects: Both subprocess paths are attempted and their coordinates are combined before resolution.

Partial resolution: When some dependencies cannot be downloaded (e.g. private repositories, network issues), a org.eclipse.aether.resolution.DependencyResolutionException is thrown with partial results. Stage 2 logs a warning and returns whatever JARs were resolved. Missing types appear as JavaType.Unknown in the LST rather than causing a hard failure.

Failure behaviour: When no subprocess succeeds, or when Maven Resolver produces an empty result, resolveClasspath returns an empty list, causing LstBuilder to fall through to BuildFileParseStage (Stage 3).

Extensibility: The class is open with open / protected open methods so tests can subclass it to inject a fake classpath without triggering network access.

Parameters

aetherContext

Shared Maven Resolver context holding the Aether RepositorySystem, session, and configured remote repositories. Create one via AetherContext.build.

Constructors

Link copied to clipboard
constructor(aetherContext: AetherContext, logger: RunnerLogger)

Functions

Link copied to clipboard

Best-effort: runs gradle dependencies to collect per-project configuration data for org.openrewrite.gradle.marker.GradleProject marker attachment. Used by LstBuilder when Stage 1 already provided the compile classpath and only marker data is still needed.

Link copied to clipboard

Resolves the project's compile classpath by running subprocesses (mvn dependency:tree and/or gradle dependencies) and downloading the resulting coordinates via Maven Resolver.