Skip to content

Commit 74f4417

Browse files
committed
GH-1035 - Prevent dynamic agent attachment warnings caused by Mockito.
Prior to this commit, running our tests caused the following warning because Mockito was dynamically self-attaching to the running JVM: Mockito is currently self-attaching to enable the inline-mock-maker. This will no longer work in future releases of the JDK. Please add Mockito as an agent to your build what is described in Mockito's documentation: https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#0.3 We now follow the advice in the provided link and set up our build accordingly. $ Conflicts: $ spring-modulith-apt/pom.xml
1 parent 2142f31 commit 74f4417

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,18 @@ limitations under the License.
496496
</configuration>
497497
</plugin>
498498

499+
<plugin>
500+
<groupId>org.apache.maven.plugins</groupId>
501+
<artifactId>maven-dependency-plugin</artifactId>
502+
<executions>
503+
<execution>
504+
<goals>
505+
<goal>properties</goal>
506+
</goals>
507+
</execution>
508+
</executions>
509+
</plugin>
510+
499511
<plugin>
500512
<groupId>org.apache.maven.plugins</groupId>
501513
<artifactId>maven-surefire-plugin</artifactId>
@@ -504,6 +516,8 @@ limitations under the License.
504516
<excludes>
505517
<exclude />
506518
</excludes>
519+
<!-- To avoid warnings of Mockito dynamically attaching an agent -->
520+
<argLine>-javaagent:${org.mockito:mockito-core:jar}</argLine>
507521
</configuration>
508522
</plugin>
509523

spring-modulith-examples/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@
5050
</annotationProcessorPaths>
5151
</configuration>
5252
</plugin>
53+
<plugin>
54+
<groupId>org.apache.maven.plugins</groupId>
55+
<artifactId>maven-dependency-plugin</artifactId>
56+
<executions>
57+
<execution>
58+
<goals>
59+
<goal>properties</goal>
60+
</goals>
61+
</execution>
62+
</executions>
63+
</plugin>
64+
<plugin>
65+
<groupId>org.apache.maven.plugins</groupId>
66+
<artifactId>maven-surefire-plugin</artifactId>
67+
<configuration>
68+
<!-- To avoid warnings of Mockito dynamically attaching an agent -->
69+
<argLine>-javaagent:${org.mockito:mockito-core:jar}</argLine>
70+
</configuration>
71+
</plugin>
5372
</plugins>
5473
</build>
5574

0 commit comments

Comments
 (0)