From ce8c5e1dc657da5cc877b98b7b4b77d1c4deceaa Mon Sep 17 00:00:00 2001 From: Andreas Sewe Date: Tue, 22 Sep 2026 15:14:27 +0200 Subject: [PATCH] TS-48018 Pass the JaCoCo class loader options on to the profiler The Gradle plugin builds the profiler's argument string from the JaCoCo task extension, but read only its include and exclude patterns. A test task that set jacoco.includeNoLocationClasses was therefore instrumented as if it had not, which records no coverage at all when the test JVM's class loader builds its own code sources. IntelliJ's PathClassLoader does, so every class of a plug-in under test went uninstrumented. The plugin dropped jacoco.excludeClassLoaders the same way. Forward the two as `jacoco-inclnolocationclasses` and `jacoco-exclclassloader`, which the agent passes on to JaCoCo. --- CHANGELOG.md | 1 + .../main/kotlin/com/teamscale/config/AgentConfiguration.kt | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8520dc37..c465196fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ We use [semantic versioning](http://semver.org/): - PATCH version when you make backwards compatible bug fixes. # Next version +- [fix] _teamscale-gradle-plugin_: `jacoco.includeNoLocationClasses` and `jacoco.excludeClassLoaders` on a test task now reach the profiler. Previously the plugin dropped both, so neither had any effect on which classes the profiler instruments. - [fix] _impacted-test-engine_: Tests in a `@ParameterizedClass` are now collected. - [fix] _impacted-test-engine_: A test failure inside a nested test container (e.g. an invocation of a `@ParameterizedClass`) is no longer swallowed. - [fix] _teamscale-jacoco-agent_, _teamscale-maven-plugin_: A test that was executed more than once (e.g. once per parameter set of a `@ParameterizedClass`) is now reported once in the testwise coverage report, with the coverage of all of its executions merged, their durations summed up and the most severe of their results. Previously each execution overwrote the previous one. diff --git a/teamscale-gradle-plugin/src/main/kotlin/com/teamscale/config/AgentConfiguration.kt b/teamscale-gradle-plugin/src/main/kotlin/com/teamscale/config/AgentConfiguration.kt index cf4753016..aa1102ac1 100644 --- a/teamscale-gradle-plugin/src/main/kotlin/com/teamscale/config/AgentConfiguration.kt +++ b/teamscale-gradle-plugin/src/main/kotlin/com/teamscale/config/AgentConfiguration.kt @@ -99,6 +99,12 @@ abstract class AgentConfiguration @Inject constructor( argument.append("out", destination.asFile.get()) argument.append("includes", jacocoExtension.includes) argument.append("excludes", jacocoExtension.excludes) + // The profiler replaces JaCoCo's own agent, so a setting it does not forward has no effect at + // all. The agent passes options prefixed `jacoco-` on to JaCoCo. + argument.append("jacoco-exclclassloader", jacocoExtension.excludeClassLoaders) + if (jacocoExtension.isIncludeNoLocationClasses) { + argument.append("jacoco-inclnolocationclasses", true) + } argument.append("mode", "testwise") argument.append("http-server-port", url.port) if (debugLogging.getOrElse(false)) {