16
16
17
17
package org .gradlex .javamodule .testing ;
18
18
19
- import org .gradle .api .file .FileCollection ;
20
- import org .gradle .testing .base .TestingExtension ;
21
- import org .gradlex .javamodule .testing .internal .ModuleInfoParser ;
22
- import org .gradlex .javamodule .testing .internal .bridges .JavaModuleDependenciesBridge ;
23
- import org .gradlex .javamodule .testing .internal .provider .WhiteboxTestCompileArgumentProvider ;
24
- import org .gradlex .javamodule .testing .internal .provider .WhiteboxTestRuntimeArgumentProvider ;
25
19
import org .gradle .api .Action ;
26
20
import org .gradle .api .Project ;
27
21
import org .gradle .api .artifacts .Configuration ;
28
22
import org .gradle .api .artifacts .ConfigurationContainer ;
29
23
import org .gradle .api .artifacts .dsl .DependencyHandler ;
24
+ import org .gradle .api .file .FileCollection ;
30
25
import org .gradle .api .plugins .jvm .JvmTestSuite ;
31
26
import org .gradle .api .provider .Provider ;
32
27
import org .gradle .api .tasks .SourceSet ;
38
33
import org .gradle .internal .jvm .JavaModuleDetector ;
39
34
import org .gradle .jvm .tasks .Jar ;
40
35
import org .gradle .testing .base .TestSuite ;
36
+ import org .gradle .testing .base .TestingExtension ;
37
+ import org .gradlex .javamodule .testing .internal .ModuleInfoParser ;
38
+ import org .gradlex .javamodule .testing .internal .bridges .JavaModuleDependenciesBridge ;
39
+ import org .gradlex .javamodule .testing .internal .provider .WhiteboxTestCompileArgumentProvider ;
40
+ import org .gradlex .javamodule .testing .internal .provider .WhiteboxTestRuntimeArgumentProvider ;
41
41
42
42
import javax .inject .Inject ;
43
43
import java .io .File ;
@@ -71,7 +71,7 @@ public JavaModuleTestingExtension(Project project, JavaModuleDetector moduleDete
71
71
/**
72
72
* Turn the given JVM Test Suite into a Blackbox Test Suite.
73
73
* For example:
74
- *
74
+ * <p>
75
75
* javaModuleTesting.blackbox(testing.suites["integtest"])
76
76
*
77
77
* @param jvmTestSuite the JVM Test Suite to configure
@@ -85,11 +85,12 @@ public void blackbox(TestSuite jvmTestSuite) {
85
85
/**
86
86
* Turn the given JVM Test Suite into a Whitebox Test Suite.
87
87
* For example:
88
- *
88
+ * <p>
89
89
* javaModuleTesting.whitebox(testing.suites["test"])
90
90
*
91
91
* @param jvmTestSuite the JVM Test Suite to configure
92
92
*/
93
+ @ SuppressWarnings ("unused" )
93
94
public void whitebox (TestSuite jvmTestSuite ) {
94
95
whitebox (jvmTestSuite , NO_OP_ACTION );
95
96
}
@@ -98,9 +99,9 @@ public void whitebox(TestSuite jvmTestSuite) {
98
99
* Turn the given JVM Test Suite into a Whitebox Test Suite.
99
100
* If needed, configure additional 'requires' and open the
100
101
* test packages for reflection.
101
- *
102
+ * <p>
102
103
* For example, for JUnit 5, you need at least:
103
- *
104
+ * <p>
104
105
* javaModuleTesting.whitebox(testing.suites["test"]) {
105
106
* requires.add("org.junit.jupiter.api")
106
107
* opensTo.add("org.junit.platform.commons")
@@ -162,12 +163,13 @@ private void configureJvmTestSuiteForWhitebox(JvmTestSuite jvmTestSuite, Whitebo
162
163
compileJava ,
163
164
syntheticModuleInfoFolders ,
164
165
moduleDetector ,
165
- moduleInfoParser );
166
+ moduleInfoParser ,
167
+ project .getObjects ());
166
168
compileJava .getOptions ().getCompilerArgumentProviders ().add (newProvider );
167
169
return newProvider ;
168
170
});
169
171
argumentProvider .testRequires (JavaModuleDependenciesBridge .getCompileClasspathModules (project , testSources ));
170
- argumentProvider .testRequires (whiteboxJvmTestSuite .getRequires (). get () );
172
+ argumentProvider .testRequires (whiteboxJvmTestSuite .getRequires ());
171
173
});
172
174
173
175
tasks .named (testSources .getName (), Test .class , test -> {
@@ -184,13 +186,14 @@ private void configureJvmTestSuiteForWhitebox(JvmTestSuite jvmTestSuite, Whitebo
184
186
testSources .getJava ().getClassesDirectory (),
185
187
sourcesUnderTest .getOutput ().getResourcesDir (),
186
188
testSources .getOutput ().getResourcesDir (),
187
- moduleInfoParser );
189
+ moduleInfoParser ,
190
+ project .getObjects ());
188
191
test .getJvmArgumentProviders ().add (newProvider );
189
192
return newProvider ;
190
193
});
191
194
argumentProvider .testRequires (JavaModuleDependenciesBridge .getRuntimeClasspathModules (project , testSources ));
192
- argumentProvider .testRequires (whiteboxJvmTestSuite .getRequires (). get () );
193
- argumentProvider .testOpensTo (whiteboxJvmTestSuite .getOpensTo (). get () );
195
+ argumentProvider .testRequires (whiteboxJvmTestSuite .getRequires ());
196
+ argumentProvider .testOpensTo (whiteboxJvmTestSuite .getOpensTo ());
194
197
});
195
198
196
199
Configuration implementation = configurations .getByName (testSources .getImplementationConfigurationName ());
0 commit comments