Skip to content

Commit 2ba7b87

Browse files
dfa1claude
andcommitted
ci: fix Mockito self-attach warning via byte-buddy-agent javaagent
Add maven-dependency-plugin:properties execution to resolve net.bytebuddy:byte-buddy-agent:jar path at build time, then load it as -javaagent in the surefire argLine. Eliminates the "Mockito is currently self-attaching" warning without version pinning. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 53dfdcb commit 2ba7b87

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

pom.xml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,18 @@
268268
<!-- {@code @{argLine}} expands to the JaCoCo agent arguments set by
269269
{@code jacoco:prepare-agent} when the {@code coverage} profile is active.
270270
Without {@code @{argLine}} the JaCoCo agent isn't attached and no
271-
coverage data is collected. -->
272-
<argLine>@{argLine} --sun-misc-unsafe-memory-access=allow --enable-native-access=ALL-UNNAMED</argLine>
271+
coverage data is collected.
272+
{@code net.bytebuddy:byte-buddy-agent:jar} is resolved to an absolute path
273+
by {@code maven-dependency-plugin:properties} (declared in build/plugins);
274+
loading it as a javaagent suppresses the Mockito self-attach warning. -->
275+
<argLine>@{argLine} -javaagent:${net.bytebuddy:byte-buddy-agent:jar} --sun-misc-unsafe-memory-access=allow --enable-native-access=ALL-UNNAMED</argLine>
273276
</configuration>
274277
</plugin>
278+
<plugin>
279+
<groupId>org.apache.maven.plugins</groupId>
280+
<artifactId>maven-dependency-plugin</artifactId>
281+
<version>3.7.0</version>
282+
</plugin>
275283
<plugin>
276284
<groupId>org.codehaus.mojo</groupId>
277285
<artifactId>exec-maven-plugin</artifactId>
@@ -358,6 +366,20 @@
358366
<groupId>org.apache.maven.plugins</groupId>
359367
<artifactId>maven-checkstyle-plugin</artifactId>
360368
</plugin>
369+
<plugin>
370+
<groupId>org.apache.maven.plugins</groupId>
371+
<artifactId>maven-dependency-plugin</artifactId>
372+
<executions>
373+
<execution>
374+
<!-- Resolves ${net.bytebuddy:byte-buddy-agent:jar} so surefire can load it
375+
as a javaagent — eliminates the Mockito inline-mock-maker self-attach warning. -->
376+
<id>locate-byte-buddy-agent</id>
377+
<goals>
378+
<goal>properties</goal>
379+
</goals>
380+
</execution>
381+
</executions>
382+
</plugin>
361383
</plugins>
362384
</build>
363385

0 commit comments

Comments
 (0)