File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed
Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,12 @@ java {
8585 }
8686}
8787
88+ configurations {
89+ if (project. testJava > 8 ) {
90+ mockitoAgent
91+ }
92+ }
93+
8894ext {
8995 // Do not upgrade to JUnit 6 as it requires Java 17
9096 junit_jupiter = ' 5.14.3'
@@ -114,6 +120,10 @@ dependencies {
114120 testImplementation " org.mockito:mockito-core:$mockito "
115121 if (project. testJava == 8 ) {
116122 testImplementation " org.mockito:mockito-inline:$mockito "
123+ } else {
124+ mockitoAgent(" org.mockito:mockito-core:$mockito " ) {
125+ transitive = false
126+ }
117127 }
118128 testImplementation " org.mockito:mockito-junit-jupiter:$mockito "
119129}
@@ -249,6 +259,13 @@ test {
249259 println " Running tests for type ${ project.'test.gds_type'} "
250260 // Use junit platform for unit tests
251261 useJUnitPlatform()
262+ if (project. testJava > 8 ) {
263+ jvmArgumentProviders. add(
264+ objects. newInstance(JavaAgentProvider ). tap {
265+ agent = configurations. mockitoAgent. asPath
266+ }
267+ )
268+ }
252269
253270 // Test configuration, defaults specified in gradle.properties (modify through ext, or use -P<prop>=<value>)
254271 systemProperties(
Original file line number Diff line number Diff line change 1+ // SPDX-FileCopyrightText: Copyright 2026 Mark Rotteveel
2+ // SPDX-License-Identifier: LGPL-2.1-or-later
3+ plugins {
4+ id ' groovy-gradle-plugin'
5+ }
6+
7+ repositories {
8+ gradlePluginPortal()
9+ }
Original file line number Diff line number Diff line change 1+ // SPDX-FileCopyrightText: Copyright 2026 Mark Rotteveel
2+ // SPDX-License-Identifier: LGPL-2.1-or-later
3+ import org.gradle.api.provider.Property
4+ import org.gradle.api.tasks.InputFile
5+ import org.gradle.api.tasks.PathSensitive
6+ import org.gradle.api.tasks.PathSensitivity
7+ import org.gradle.process.CommandLineArgumentProvider
8+
9+ /**
10+ * Provider for {@code -javaagent:some.jar } command line arguments.
11+ */
12+ abstract class JavaAgentProvider implements CommandLineArgumentProvider {
13+
14+ @InputFile
15+ @PathSensitive (PathSensitivity .RELATIVE )
16+ abstract Property<String > getAgent ()
17+
18+ @Override
19+ Iterable<String > asArguments () {
20+ [" -javaagent:${ agent.get()} " ]
21+ }
22+
23+ }
You can’t perform that action at this time.
0 commit comments