24
24
import org .elasticsearch .gradle .info .GlobalBuildInfoPlugin ;
25
25
import org .elasticsearch .gradle .test .ErrorReportingTestListener ;
26
26
import org .elasticsearch .gradle .util .Util ;
27
+ import org .gradle .api .Action ;
27
28
import org .gradle .api .GradleException ;
28
29
import org .gradle .api .JavaVersion ;
29
30
import org .gradle .api .Plugin ;
30
31
import org .gradle .api .Project ;
32
+ import org .gradle .api .Task ;
31
33
import org .gradle .api .artifacts .Configuration ;
32
34
import org .gradle .api .artifacts .ModuleDependency ;
33
35
import org .gradle .api .artifacts .ProjectDependency ;
@@ -241,14 +243,19 @@ public static void configureTestTasks(Project project) {
241
243
*/
242
244
SystemPropertyCommandLineArgumentProvider nonInputProperties = new SystemPropertyCommandLineArgumentProvider ();
243
245
244
- test .doFirst (t -> {
245
- project .mkdir (testOutputDir );
246
- project .mkdir (heapdumpDir );
247
- project .mkdir (test .getWorkingDir ());
248
- project .mkdir (test .getWorkingDir ().toPath ().resolve ("temp" ));
249
-
250
- // TODO remove once jvm.options are added to test system properties
251
- test .systemProperty ("java.locale.providers" , "SPI,COMPAT" );
246
+ // We specifically use an anonymous inner class here because lambda task actions break Gradle cacheability
247
+ // See: https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:how_does_it_work
248
+ test .doFirst (new Action <>() {
249
+ @ Override
250
+ public void execute (Task t ) {
251
+ project .mkdir (testOutputDir );
252
+ project .mkdir (heapdumpDir );
253
+ project .mkdir (test .getWorkingDir ());
254
+ project .mkdir (test .getWorkingDir ().toPath ().resolve ("temp" ));
255
+
256
+ // TODO remove once jvm.options are added to test system properties
257
+ test .systemProperty ("java.locale.providers" , "SPI,COMPAT" );
258
+ }
252
259
});
253
260
if (BuildParams .isInFipsJvm ()) {
254
261
project .getDependencies ().add ("testRuntimeOnly" , "org.bouncycastle:bc-fips:1.0.1" );
@@ -269,7 +276,7 @@ public static void configureTestTasks(Project project) {
269
276
"-XX:+HeapDumpOnOutOfMemoryError"
270
277
);
271
278
272
- test .getJvmArgumentProviders ().add (() -> List . of ("-XX:HeapDumpPath=$heapdumpDir" ));
279
+ test .getJvmArgumentProviders ().add (new SimpleCommandLineArgumentProvider ("-XX:HeapDumpPath=" + heapdumpDir ));
273
280
274
281
String argline = System .getProperty ("tests.jvm.argline" );
275
282
if (argline != null ) {
0 commit comments