Skip to content

Commit f6dd783

Browse files
committed
GH-1033 - 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.
1 parent dcde353 commit f6dd783

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,27 @@ limitations under the License.
562562
</configuration>
563563
</plugin>
564564

565+
<plugin>
566+
<groupId>org.apache.maven.plugins</groupId>
567+
<artifactId>maven-dependency-plugin</artifactId>
568+
<executions>
569+
<execution>
570+
<goals>
571+
<goal>properties</goal>
572+
</goals>
573+
</execution>
574+
</executions>
575+
</plugin>
576+
565577
<plugin>
566578
<groupId>org.apache.maven.plugins</groupId>
567579
<artifactId>maven-surefire-plugin</artifactId>
568580
<configuration>
569581
<excludes>
570582
<exclude />
571583
</excludes>
584+
<!-- To avoid warnings of Mockito dynamically attaching an agent -->
585+
<argLine>-javaagent:${org.mockito:mockito-core:jar}</argLine>
572586
</configuration>
573587
</plugin>
574588

spring-modulith-apt/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
<scope>test</scope>
6464
</dependency>
6565

66+
<dependency>
67+
<groupId>org.mockito</groupId>
68+
<artifactId>mockito-core</artifactId>
69+
<scope>test</scope>
70+
</dependency>
71+
6672
</dependencies>
6773

6874
<build>

spring-modulith-examples/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@
9393
</annotationProcessorPaths>
9494
</configuration>
9595
</plugin>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-dependency-plugin</artifactId>
99+
<executions>
100+
<execution>
101+
<goals>
102+
<goal>properties</goal>
103+
</goals>
104+
</execution>
105+
</executions>
106+
</plugin>
107+
<plugin>
108+
<groupId>org.apache.maven.plugins</groupId>
109+
<artifactId>maven-surefire-plugin</artifactId>
110+
<configuration>
111+
<!-- To avoid warnings of Mockito dynamically attaching an agent -->
112+
<argLine>-javaagent:${org.mockito:mockito-core:jar}</argLine>
113+
</configuration>
114+
</plugin>
96115
</plugins>
97116
</build>
98117

0 commit comments

Comments
 (0)