tryCompile

open fun tryCompile(projectDir: Path): Boolean(source)

Attempts to compile the project using its build tool.

Called by LstBuilder after a successful extractClasspath when no pre-compiled class directories are found (target/classes, build/classes/java/main, etc.). Compilation makes the project's own .class files available on the classpath, so intra-project type references and wildcard imports within the project itself resolve correctly during OpenRewrite's type-attribution phase.

Runs mvn compile -q for Maven or gradle classes -q for Gradle. Uses the project wrapper (mvnw / gradlew) when present.

Return

true if compilation exited with code 0; false on any failure (non-zero exit, missing build tool, or exception). Never throws — failure is logged as a warning and the pipeline continues without compiled class directories.