LstBuilder

open class LstBuilder(logger: RunnerLogger, cacheDir: Path, toolConfig: ToolConfig, aetherContext: AetherContext = AetherContext.build( localRepoDir = Paths.get(System.getProperty("user.home"), ".m2", "repository"), extraRepositories = toolConfig.resolvedRepositories(), logger = logger ), projectBuildStage: ProjectBuildStage = ProjectBuildStage(logger), depResolutionStage: DependencyResolutionStage = DependencyResolutionStage( aetherContext, logger ), buildFileParseStage: BuildFileParseStage = BuildFileParseStage( aetherContext, logger ))(source)

Orchestrates the 4-stage LST building pipeline and multi-language file parsing.

Classpath resolution (4 stages) — runs once per build invocation and the result is shared by all JVM language parsers (Java, Kotlin, Groovy):

  • Stage 1 — ProjectBuildStage Run the project's own build tool (Maven/Gradle) to extract the compile classpath.

  • Stage 2 — DependencyResolutionStage Run mvn dependency:tree / gradle dependencies subprocesses and resolve via Maven Resolver.

  • Stage 3 — BuildFileParseStage Parse build files statically and resolve via Maven Resolver POM traversal.

  • Stage 4 — LocalRepositoryStage Scan ~/.m2 / ~/.gradle/caches for already-cached JARs matching declared deps.

Gradle DSL classpath — an additional classpath resolved from the Gradle installation (via GRADLE_HOME, the project's Gradle wrapper, or ~/.gradle/wrapper/dists/) is added on top of the regular classpath exclusively for Gradle script files:

  • .gradle — Groovy DSL build scripts

  • *.gradle.kts — Kotlin DSL build scripts (e.g. build.gradle.kts, settings.gradle.kts)

Plain .kt sources and non-Gradle .kts scripts receive only the regular project classpath.

Java/Kotlin version detection — each .java, .kt, and .kts source file receives a org.openrewrite.java.marker.JavaVersion marker whose sourceCompatibility/targetCompatibility values reflect the nearest build descriptor found by walking up from the file's own directory toward build's projectDir. See io.github.skhokhlov.rewriterunner.lst.utils.VersionDetector for the full algorithm.

Maven POM parsingpom.xml files are routed to org.openrewrite.maven.MavenParser, producing Xml.Document nodes annotated with org.openrewrite.maven.tree.MavenResolutionResult and related Maven markers. All other *.xml files use org.openrewrite.xml.XmlParser.

Constructors

Link copied to clipboard
constructor(logger: RunnerLogger, cacheDir: Path, toolConfig: ToolConfig, aetherContext: AetherContext = AetherContext.build( localRepoDir = Paths.get(System.getProperty("user.home"), ".m2", "repository"), extraRepositories = toolConfig.resolvedRepositories(), logger = logger ), projectBuildStage: ProjectBuildStage = ProjectBuildStage(logger), depResolutionStage: DependencyResolutionStage = DependencyResolutionStage( aetherContext, logger ), buildFileParseStage: BuildFileParseStage = BuildFileParseStage( aetherContext, logger ))

Functions

Link copied to clipboard
fun build(projectDir: Path, parseConfig: ParseConfig = toolConfig.parse, includeExtensionsCli: List<String> = emptyList(), excludeExtensionsCli: List<String> = emptyList(), ctx: ExecutionContext = InMemoryExecutionContext {}): List<SourceFile>

Parse all source files in projectDir into OpenRewrite SourceFile trees.