fix: resolve missing project JARs in Gradle multi-module classpath#1981
fix: resolve missing project JARs in Gradle multi-module classpath#1981HeshamHM28 wants to merge 3 commits intomainfrom
Conversation
Gradle's testRuntimeClasspath resolves project dependencies to JAR files (build/libs/*.jar), but testClasses only compiles classes without building JARs. This caused all tests to fail in multi-module projects like OpenRewrite where 11 critical dependency JARs were missing from the classpath. Changes: - Add _resolve_project_classpath() to detect missing project JARs and replace them with build/classes/*/main + build/resources/main directories - Add _compile_dependency_modules() to compile testRuntimeOnly project deps (e.g. rewrite-java-21) that testClasses skips - Fix _extract_modules_from_settings_gradle() to parse multi-line include(), Kotlin listOf() variable declarations, and Groovy-style includes - Remove old partial multi-module classpath supplement (superseded) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @HeshamHM28's task in 4m 40s —— View job PR Review SummaryTasks
Prek ChecksFixed automatically: Mypy: clean, no issues. Code ReviewBug: missing JAR silently dropped when no replacement is found
if not added:
logger.warning("No class/resource directories found for missing JAR: %s", entry)
# entry is omitted entirely — nothing appended to result_entriesA missing JAR is better than a missing classpath entry: the JVM will fail with a clear if not added:
logger.warning("No class/resource directories found for missing JAR: %s — keeping original entry", entry)
result_entries.append(entry) # keep original even if JAR doesn't existDesign:
|
…tions - Replace fragile multi-regex settings.gradle parser with a single broad pattern that extracts all quoted module identifiers, handling any DSL style - Add _scan_filesystem_for_modules() as fallback when settings parsing fails - Fix all test assertions to use full string equality (== []) not substring (in) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Hesham Mohamed <undefined@users.noreply.github.com>
Summary
testRuntimeClasspathresolves project dependencies to JAR files (build/libs/*.jar), buttestClassesonly compiles classes — it doesn't build JARs. This caused direct JVM test execution to fail in multi-module projects (e.g. OpenRewrite: 11 missing JARs). New_resolve_project_classpath()detects missing project JARs and replaces them withbuild/classes/*/main+build/resources/maindirectories. Also compilestestRuntimeOnlyproject deps thattestClassesskips._extract_modules_from_settings_gradle()couldn't parse Kotlin-stylelistOf()variable declarations or multi-lineinclude()calls (e.g. OpenRewrite'ssettings.gradle.kts). This caused the test runner to fall back to root-level Gradle execution, triggering unrelated subproject builds.Verified against OpenRewrite (32-module Gradle project)
IllegalStateException: Unable to create a Java parser instance→ all tests failtestRuntimeOnlymodules auto-compiled, tests pass via direct JVMTest plan
_resolve_project_classpathand_compile_dependency_modules_extract_modules_from_settings_gradle(multi-line,listOf, Groovy)AnnotationMatcherTest(RewriteTest framework, cross-module deps) passes via direct JVM on OpenRewriteprekpasses🤖 Generated with Claude Code