fix: Gradle JAR resolution, JaCoCo agent coverage, and multi-module settings.gradle parsing#2013
fix: Gradle JAR resolution, JaCoCo agent coverage, and multi-module settings.gradle parsing#2013mashraf-222 wants to merge 8 commits intomainfrom
Conversation
…tion Gradle projects and the tracer flow could not resolve codeflash-runtime when no local JAR was cached — the bundled JAR was removed in PR #1817 but the download fallback was only added to MavenStrategy. This adds a direct HTTP download from Maven Central (no mvn binary required) as a fallback in GradleStrategy.ensure_runtime() and find_agent_jar(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @mashraf-222's task in 2s —— View job PR Review SummaryPrek ChecksClean — ruff and mypy report no issues on changed files. Code ReviewBug: Partial download not cleaned up in JaCoCo JAR fetchers [
|
…rage The previous approach failed on multi-module Gradle projects (e.g., eureka) where the root project doesn't have the java plugin — appending `jacocoTestReport` as a root-level task caused "Task not found" errors. Three changes: 1. Fixed _JACOCO_INIT_SCRIPT to guard with `plugins.withType(JavaPlugin)` so JaCoCo only applies to projects that have the java plugin 2. Pass the init script via --init-script (was defined but never used) 3. Qualify jacocoTestReport with module prefix (`:module:jacocoTestReport`) for multi-module projects 4. Simplified setup_coverage() — init script handles plugin injection, no more build file modification needed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gradle with --no-daemon + coverage on multi-module projects (e.g., eureka) needs cold startup + configuration + compilation + tests + JaCoCo report generation, which exceeds 300s. Validated on eureka: build was killed at exactly 300s, now gets 600s. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two fixes for Gradle multi-module project support: 1. _extract_modules_from_settings_gradle regex now handles multi-line include statements (comma-continued across lines). Previously only the first line was captured, causing module detection to miss most modules in projects like eureka. This made Gradle run `test` at root level instead of `:eureka-core:test`, triggering all-module compilation. 2. Increased coverage min_timeout from 300s to 900s — Gradle --no-daemon on large projects needs ~10min for cold startup + compilation + tests, plus ~3min for JaCoCo report generation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous approach used a Gradle init script to inject the JaCoCo plugin and ran jacocoTestReport as a Gradle task. On large multi-module projects (e.g., eureka), this added 5-10 minutes of Gradle overhead for report generation, causing persistent timeouts. Switch to the JaCoCo Java agent approach: - Inject -javaagent:jacocoagent.jar via JAVA_TOOL_OPTIONS env var - Coverage data collected during test execution with near-zero overhead - Convert .exec to .xml using JaCoCo CLI after tests complete (~2 seconds) - No Gradle plugin, init script, or jacocoTestReport task needed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Eureka-core with --no-daemon takes ~10 min for cold startup + compilation + test execution. The 600s timeout was too tight — tests completed but Gradle was killed during shutdown. 900s provides sufficient buffer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
E2E ValidationSetup# Branch: fix/gradle-tracer-jar-resolution (commit 6c40422f)
# Cleared ~/.m2/repository/com/codeflash/codeflash-runtime/
# Local BE services running (CF API :3001, AI Service :8000)
export CODEFLASH_CFAPI_SERVER="local"
export CODEFLASH_AIS_SERVER="local"Run 1: Fibonacci (Maven regression check)cd code_to_optimize/java/
uv run codeflash --file src/main/java/com/example/Fibonacci.java --function fibonacci --verbose --no-prResult: PASS — Full Maven pipeline healthy, ~16,000x memoization speedup found. No regressions. Run 2: eureka toEnum (Gradle — validates all fixes)cd /home/ubuntu/code/eureka/
uv run codeflash --file eureka-core/src/main/java/com/netflix/eureka/Version.java --function toEnum --verbose --no-pr
Result: PASS — All 3 Gradle fixes validated. No optimization found (expected for this function), but full pipeline completed correctly. |
Problems Fixed
1. Gradle/tracer JAR resolution fails when not in Maven cache
When the codeflash-runtime JAR wasn't in the local Maven cache, Gradle projects had no fallback.
2. JaCoCo coverage times out on large Gradle projects
The previous JaCoCo implementation used a Gradle init script +
jacocoTestReporttask. On large multi-module projects (e.g., eureka), this added 5-10 minutes of Gradle overhead, causing persistent timeouts.3. Multi-line settings.gradle includes not parsed
The regex only captured the first line of multi-line
includestatements, causingtest_module=Noneand Gradle running tests across ALL modules.Solutions
1. Maven Central HTTP fallback
Added
download_from_maven_central_http()for both runtime and tracer JARs.2. JaCoCo agent approach (replaces Gradle plugin)
jacocoagent.jarandjacococli.jarfrom Maven Central (cached in~/.codeflash/java_agents/)-javaagent:jacocoagent.jarviaJAVA_TOOL_OPTIONSenv var.execto.xmlusing JaCoCo CLI after tests (~2 seconds)jacocoTestReporttask needed3. Multi-line settings.gradle regex fix
New regex handles comma-continued lines across multiple lines.
4. Coverage timeout increase (900s)
Large multi-module Gradle projects with
--no-daemon(cold JVM startup + compilation + test execution) can take 10+ minutes. Increasedmin_timeoutfrom 120s to 900s for coverage runs.Code Changes
gradle_strategy.pyJAVA_TOOL_OPTIONS,.exec→.xmlCLI conversion, agent/CLI JAR download helpersmaven_strategy.pydownload_from_maven_central_http()fallback for runtime JARtest_runner.pymin_timeout120→900s, simplified coverage loggingtest_build_tools.pytest_java_test_paths.pyE2E Validation
Fibonacci (Maven — regression check)
Full pipeline healthy. ~16,000x memoization speedup found. No regressions from Gradle changes.
eureka toEnum (Gradle — validates all 3 fixes)