From 86722a704a7e65bbf43da84c124f7b7b5e7a1436 Mon Sep 17 00:00:00 2001 From: Damian Momot Date: Mon, 7 Sep 2026 04:11:46 -0700 Subject: [PATCH] build: load Mockito as a startup Java agent for surefire tests Mockito 5's inline mock maker self-attaches its agent to the running JVM at runtime, which newer JDKs block, causing `mvn test` to fail with "Could not initialize plugin: org.mockito.plugins.MockMaker". Load mockito-core as a `-javaagent` (via maven-dependency-plugin resolving its jar path and a per-module surefire argLine) so the inline mock maker initializes from a startup agent instead of self-attaching. PiperOrigin-RevId: 977402752 --- a2a/pom.xml | 3 +++ contrib/firestore-session-service/pom.xml | 6 ++++++ contrib/langchain4j/pom.xml | 5 +++++ contrib/planners/pom.xml | 6 ++++++ contrib/spring-ai/pom.xml | 3 +++ core/pom.xml | 6 +++++- dev/pom.xml | 5 +++++ pom.xml | 24 ++++++++++++++++++++++- 8 files changed, 56 insertions(+), 2 deletions(-) diff --git a/a2a/pom.xml b/a2a/pom.xml index c5948508e..8e6c320a8 100644 --- a/a2a/pom.xml +++ b/a2a/pom.xml @@ -24,6 +24,9 @@ 2.0.17 1.4.4 4.13.2 + + -javaagent:${org.mockito:mockito-core:jar} diff --git a/contrib/firestore-session-service/pom.xml b/contrib/firestore-session-service/pom.xml index d24ab86f8..fc64812ae 100644 --- a/contrib/firestore-session-service/pom.xml +++ b/contrib/firestore-session-service/pom.xml @@ -28,6 +28,11 @@ Agent Development Kit - Firestore Session Management Firestore integration with Agent Development Kit for User Session Management + + + -javaagent:${org.mockito:mockito-core:jar} + @@ -90,6 +95,7 @@ maven-surefire-plugin + ${mockito.javaagent.arg} ${jacoco.agent.argLine} --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED diff --git a/contrib/langchain4j/pom.xml b/contrib/langchain4j/pom.xml index 60f222946..7859fec80 100644 --- a/contrib/langchain4j/pom.xml +++ b/contrib/langchain4j/pom.xml @@ -28,6 +28,11 @@ Agent Development Kit - LangChain4j LangChain4j integration for the Agent Development Kit. + + + -javaagent:${org.mockito:mockito-core:jar} + diff --git a/contrib/planners/pom.xml b/contrib/planners/pom.xml index c9dcf6261..3699c1031 100644 --- a/contrib/planners/pom.xml +++ b/contrib/planners/pom.xml @@ -28,6 +28,12 @@ Agent Development Kit - Planners Built-in planner implementations for the ADK PlannerAgent, including GOAP (Goal-Oriented Action Planning), P2P (Peer-to-Peer), and Supervisor planners. + + + -javaagent:${org.mockito:mockito-core:jar} + + diff --git a/contrib/spring-ai/pom.xml b/contrib/spring-ai/pom.xml index ca2f0240b..2a6b1143b 100644 --- a/contrib/spring-ai/pom.xml +++ b/contrib/spring-ai/pom.xml @@ -31,6 +31,9 @@ 2.0.1 1.21.3 + + -javaagent:${org.mockito:mockito-core:jar} diff --git a/core/pom.xml b/core/pom.xml index 82cdb0a9e..86bf91d29 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -27,7 +27,11 @@ Agent Development Kit Agent Development Kit: an open-source, code-first toolkit designed to simplify building, evaluating, and deploying advanced AI agents anywhere. - + + + -javaagent:${org.mockito:mockito-core:jar} + diff --git a/dev/pom.xml b/dev/pom.xml index b27c3b995..10dd4cfda 100644 --- a/dev/pom.xml +++ b/dev/pom.xml @@ -25,6 +25,11 @@ Agent Development Kit - Dev Tools Development tools and server for Agent Development Kit. + + + -javaagent:${org.mockito:mockito-core:jar} + diff --git a/pom.xml b/pom.xml index 9a689382e..26e40b432 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,12 @@ 3.9.0 5.6.1 4.1.118.Final - @{jacoco.agent.argLine} --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true + + + ${mockito.javaagent.arg} @{jacoco.agent.argLine} --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true @@ -492,6 +497,23 @@ + + + org.apache.maven.plugins + maven-dependency-plugin + 3.8.1 + + + resolve-dependency-paths + initialize + + properties + + + +