Skip to content

Commit d58b075

Browse files
committed
Load JaCoCo before our agent
1 parent 0c3a030 commit d58b075

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

agent_api/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ dependencies {
4646
test {
4747
jvmArgs '--add-opens', 'java.base/java.util=ALL-UNNAMED'
4848
jvmArgs '--add-opens', 'java.base/java.lang=ALL-UNNAMED'
49-
jvmArgs "-javaagent:${project.rootDir}/dist/agent.jar=mode=daemon-disabled"
5049
jvmArgs '-Dnet.bytebuddy.experimental=true' // Mockito support.
5150

5251
systemProperty 'AIK_agent_dir', "${project.rootDir}/dist"
@@ -64,6 +63,13 @@ test {
6463
jacoco {
6564
enabled = true
6665
}
66+
doFirst {
67+
// JaCoCo's javaagent must load before our own agent.jar. Our agent registers a
68+
// retransformation-capable ByteBuddy transformer; if it loads first, JaCoCo silently
69+
// stops recording coverage for almost every class, not just the ones we instrument.
70+
jvmArgs jacoco.getAsJvmArg(), "-javaagent:${project.rootDir}/dist/agent.jar=mode=daemon-disabled"
71+
jacoco.enabled = false
72+
}
6773
}
6874

6975
jacocoTestReport {

0 commit comments

Comments
 (0)