This is an automated email from the ASF dual-hosted git repository.
pvillard31 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new eb2a1f39c60 NIFI-16202 Switch Mockito attachment to Java Agent (#11612)
eb2a1f39c60 is described below
commit eb2a1f39c60751b09c416e5817cc8fee28590ac7
Author: David Handermann <[email protected]>
AuthorDate: Wed Sep 2 14:49:52 2026 -0500
NIFI-16202 Switch Mockito attachment to Java Agent (#11612)
- Moved argLine configuration from GitHub workflow to Maven properties
---
.github/workflows/build.yml | 2 --
nifi-manifest/nifi-runtime-manifest/pom.xml | 5 ++++
pom.xml | 37 +++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e4885d52074..2d0c149649e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -330,7 +330,6 @@ jobs:
-Duser.timezone=Asia/Tokyo
MAVEN_OPTS: >-
${{ env.DEFAULT_MAVEN_OPTS }}
- -DargLine=${env.SUREFIRE_OPTS}
run: >-
${{ env.MAVEN_COMMAND }}
${{ env.MAVEN_VERIFY_COMMAND }}
@@ -405,7 +404,6 @@ jobs:
-Duser.timezone=Europe/Paris
MAVEN_OPTS: >-
${{ env.DEFAULT_MAVEN_OPTS }}
- -DargLine=${env.SUREFIRE_OPTS}
run: >-
${{ env.MAVEN_COMMAND_WINDOWS }}
${{ env.MAVEN_VERIFY_COMMAND }}
diff --git a/nifi-manifest/nifi-runtime-manifest/pom.xml
b/nifi-manifest/nifi-runtime-manifest/pom.xml
index cc156a5eea3..be77cc340b3 100644
--- a/nifi-manifest/nifi-runtime-manifest/pom.xml
+++ b/nifi-manifest/nifi-runtime-manifest/pom.xml
@@ -69,6 +69,11 @@
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
+ <!-- This module has no tests and does not need the
Mockito Java Agent -->
+ <execution>
+ <id>resolve-mockito-agent-path</id>
+ <phase>none</phase>
+ </execution>
<execution>
<id>extract-extension-manifests</id>
<goals>
diff --git a/pom.xml b/pom.xml
index 07ac9a35845..98ba57014e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -216,6 +216,10 @@
<checkstyle.version>14.0.0</checkstyle.version>
<testcontainers.version>2.0.5</testcontainers.version>
<jacoco.version>0.8.15</jacoco.version>
+
+ <!-- Surefire argument properties for plugin and environment wiring -->
+ <argLine/>
+ <surefire.opts/>
</properties>
<dependencyManagement>
<dependencies>
@@ -742,6 +746,16 @@
<exclude>**/*ITSpec.class</exclude>
</excludes>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <!-- Runs Mockito as a Java Agent instead of relying
on self-attachment -->
+ <argLine>@{argLine} ${surefire.opts}
-javaagent:"${org.mockito:mockito-core:jar}"</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <!-- Runs Mockito as a Java Agent instead of relying
on self-attachment -->
+ <argLine>@{argLine} ${surefire.opts}
-javaagent:"${org.mockito:mockito-core:jar}"</argLine>
</configuration>
</plugin>
<plugin>
@@ -1012,6 +1026,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <!-- Sets org.mockito:mockito-core:jar to the resolved
artifact path for the Surefire argument line -->
+ <execution>
+ <id>resolve-mockito-agent-path</id>
+ <phase>initialize</phase>
+ <goals>
+ <goal>properties</goal>
+ </goals>
+ </execution>
+ </executions>
<configuration>
<ignoredPackagings>
<ignoredPackaging>nar</ignoredPackaging>
@@ -1103,6 +1127,19 @@
</plugins>
</build>
<profiles>
+ <!-- Apply Java arguments from the SUREFIRE_OPTS environment variable
to forked Surefire processes -->
+ <profile>
+ <id>surefire-opts</id>
+ <activation>
+ <property>
+ <name>env.SUREFIRE_OPTS</name>
+ </property>
+ </activation>
+ <properties>
+ <surefire.opts>${env.SUREFIRE_OPTS}</surefire.opts>
+ </properties>
+ </profile>
+
<!-- Configure build properties for modules with NAR packaging -->
<profile>
<id>nar-packaging</id>