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
This commit is contained in:
Oliver Drotbohm
2025-01-23 16:53:00 +01:00
parent 2142f3145b
commit 74f4417cd9
2 changed files with 33 additions and 0 deletions

14
pom.xml
View File

@@ -496,6 +496,18 @@ limitations under the License.
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
@@ -504,6 +516,8 @@ limitations under the License.
<excludes>
<exclude />
</excludes>
<!-- To avoid warnings of Mockito dynamically attaching an agent -->
<argLine>-javaagent:${org.mockito:mockito-core:jar}</argLine>
</configuration>
</plugin>

View File

@@ -50,6 +50,25 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- To avoid warnings of Mockito dynamically attaching an agent -->
<argLine>-javaagent:${org.mockito:mockito-core:jar}</argLine>
</configuration>
</plugin>
</plugins>
</build>