Skip to content

Apache Lucene open-source search software

Enable configuration cache (test tasks) (#15384)

Dawid Weiss146ef0374f8c
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ModularPathsExtension.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ModularPathsExtension.java
index a664201c666..0aee7689be7 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ModularPathsExtension.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ModularPathsExtension.java
@@ -17,15 +17,11 @@
package org.apache.lucene.gradle.plugins.java;
import java.io.File;
-import java.nio.file.Path;
-import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.Callable;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -35,7 +31,7 @@ import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.attributes.LibraryElements;
import org.gradle.api.file.FileCollection;
-import org.gradle.api.logging.Logger;
+import org.gradle.api.file.FileSystemLocation;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.SourceSet;
import org.gradle.process.CommandLineArgumentProvider;
@@ -72,11 +68,14 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
/** More verbose debugging for paths. */
private boolean debugPaths;
+ final boolean hasModuleDescriptor;
+
/**
* A list of module name - path provider entries that will be converted into {@code
* --patch-module} options.
*/
- private final List<Map.Entry<String, Provider<Path>>> modulePatches = new ArrayList<>();
+ private final List<Map.Entry<String, Provider<? extends FileSystemLocation>>> modulePatches =
+ new ArrayList<>();
public ModularPathsExtension(Project project, SourceSet sourceSet) {
this.project = project;
@@ -84,6 +83,10 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
// enable to debug paths.
this.debugPaths = false;
+ this.hasModuleDescriptor =
+ sourceSet.getAllJava().getSrcDirs().stream()
+ .map(dir -> new File(dir, "module-info.java"))
+ .anyMatch(File::exists);
ConfigurationContainer configurations = project.getConfigurations();
@@ -159,8 +162,23 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
* Adds {@code --patch-module} option for the provided module name and the provider of a folder or
* JAR file.
*/
- public void patchModule(String moduleName, Provider<Path> pathProvider) {
- modulePatches.add(new AbstractMap.SimpleImmutableEntry<>(moduleName, pathProvider));
+ public void patchModule(String moduleName, Provider<? extends FileSystemLocation> pathProvider) {
+ modulePatches.add(Map.entry(moduleName, pathProvider));
+ }
+
+ public void patchModule(String moduleName, FileCollection singleFileCollection) {
+ patchModule(
+ moduleName,
+ singleFileCollection
+ .getElements()
+ .map(
+ elements -> {
+ if (elements.size() != 1) {
+ throw new RuntimeException(
+ "Expected a single file as an argument for patchModule.");
+ }
+ return elements.iterator().next();
+ }));
}
private FileCollection getCompilationModulePath() {
@@ -172,7 +190,7 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
private FileCollection getRuntimeModulePath() {
if (mode == Mode.CLASSPATH_ONLY) {
- if (hasModuleDescriptor()) {
+ if (hasModuleDescriptor) {
throw new GradleException(
"Source set contains a module but classpath-only dependencies requested: "
+ project.getPath()
@@ -186,28 +204,34 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
}
private FileCollection removeNonExisting(FileCollection fc) {
- return fc.filter(File::exists);
+ return fc.filter(file -> file.exists());
}
public FileCollection getCompilationClasspath() {
+ var compileClasspath = sourceSet.getCompileClasspath();
+
if (mode == Mode.CLASSPATH_ONLY) {
return removeNonExisting(sourceSet.getCompileClasspath());
}
- // Lazy computation to subtract module-path artifacts (and patches) from compile classpath.
return removeNonExisting(
- project.files(
- (Callable<Object>)
- () ->
- sourceSet
- .getCompileClasspath()
- .minus(compileModulePathConfiguration)
- .minus(modulePatchOnlyConfiguration)));
+ compileClasspath.minus(compileModulePathConfiguration).minus(modulePatchOnlyConfiguration));
}
public CommandLineArgumentProvider getCompilationArguments() {
- return () -> {
- FileCollection modulePath = getCompilationModulePath();
+ return new CompilationArgumentsProvider(
+ getCompilationModulePath(), hasModuleDescriptor, modulePatches);
+ }
+
+ /** Keep this class static to avoid references to the outer class. */
+ public record CompilationArgumentsProvider(
+ FileCollection modulePath,
+ boolean hasModuleDescriptor,
+ List<Map.Entry<String, Provider<? extends FileSystemLocation>>> modulePatches)
+ implements CommandLineArgumentProvider {
+
+ @Override
+ public Iterable<String> asArguments() {
if (modulePath.isEmpty()) {
return List.of();
}
@@ -216,7 +240,7 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
extraArgs.add("--module-path");
extraArgs.add(joinPaths(modulePath));
- if (!hasModuleDescriptor()) {
+ if (!hasModuleDescriptor) {
// We're compiling what appears to be a non-module source set so we'll
// bring everything on module path in the resolution graph,
// otherwise modular dependencies wouldn't be part of the resolved module graph and this
@@ -229,20 +253,16 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
extraArgs.addAll(getPatchModuleArguments(modulePatches));
return extraArgs;
- };
+ }
}
public FileCollection getRuntimeClasspath() {
+ var runtimeClasspath = sourceSet.getRuntimeClasspath();
+
if (mode == Mode.CLASSPATH_ONLY) {
- return sourceSet.getRuntimeClasspath();
+ return runtimeClasspath;
}
- return project.files(
- (Callable<Object>)
- () ->
- sourceSet
- .getRuntimeClasspath()
- .minus(getRuntimeModulePath())
- .minus(modulePatchOnlyConfiguration));
+ return runtimeClasspath.minus(getRuntimeModulePath()).minus(modulePatchOnlyConfiguration);
}
/**
@@ -255,27 +275,32 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
* indirectly added by gradle internal logic.
*/
public FileCollection getTestRuntimeClasspath() {
+ var runtimeClasspath = sourceSet.getRuntimeClasspath();
+
if (mode == Mode.CLASSPATH_ONLY) {
- return sourceSet.getRuntimeClasspath();
+ return runtimeClasspath;
}
- return project.files(
- (Callable<Object>)
- () ->
- sourceSet
- .getRuntimeClasspath()
- .minus(getRuntimeModulePath())
- .minus(modulePatchOnlyConfiguration)
- .plus(
- sourceSet
- .getRuntimeClasspath()
- .filter(file -> file.getName().contains("junit"))));
+ return runtimeClasspath
+ .minus(getRuntimeModulePath())
+ .minus(modulePatchOnlyConfiguration)
+ .plus(runtimeModulePathConfiguration.filter(file -> file.getName().contains("junit")));
}
public CommandLineArgumentProvider getRuntimeArguments() {
- return () -> {
- FileCollection modulePath = getRuntimeModulePath();
+ return new RuntimeArgumentsProvider(getRuntimeModulePath(), hasModuleDescriptor, modulePatches);
+ }
+
+ /** Keep this class static to avoid references to the outer class. */
+ public record RuntimeArgumentsProvider(
+ FileCollection modulePath,
+ boolean hasModuleDescriptor,
+ List<Map.Entry<String, Provider<? extends FileSystemLocation>>> modulePatches)
+ implements CommandLineArgumentProvider {
+
+ @Override
+ public Iterable<String> asArguments() {
if (modulePath.isEmpty()) {
- return Collections.emptyList();
+ return List.of();
}
List<String> extraArgs = new ArrayList<>();
@@ -285,10 +310,8 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
extraArgs.add(joinPaths(modulePath));
// Ideally, we should only add the sourceset's module here, everything else would be resolved
- // via the
- // module descriptor. But this would require parsing the module descriptor and may cause JVM
- // version conflicts
- // so keeping it simple.
+ // via the module descriptor. But this would require parsing the module descriptor and may
+ // cause JVM version conflicts so keeping it simple.
extraArgs.add("--add-modules");
extraArgs.add("ALL-MODULE-PATH");
@@ -296,21 +319,15 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
extraArgs.addAll(getPatchModuleArguments(modulePatches));
return extraArgs;
- };
- }
-
- public boolean hasModuleDescriptor() {
- return sourceSet.getAllJava().getSrcDirs().stream()
- .map(dir -> new File(dir, "module-info.java"))
- .anyMatch(File::exists);
+ }
}
private static List<String> getPatchModuleArguments(
- List<Map.Entry<String, Provider<Path>>> patches) {
+ List<Map.Entry<String, Provider<? extends FileSystemLocation>>> modulePatches) {
List<String> args = new ArrayList<>();
- for (Map.Entry<String, Provider<Path>> e : patches) {
+ for (var e : modulePatches) {
args.add("--patch-module");
- args.add(e.getKey() + "=" + e.getValue().get());
+ args.add(e.getKey() + "=" + e.getValue().get().getAsFile());
}
return args;
}
@@ -326,43 +343,32 @@ public class ModularPathsExtension implements Cloneable, Iterable<Configuration>
.collect(Collectors.joining("\n"));
}
- private static String toList(List<Map.Entry<String, Provider<Path>>> patches) {
+ private static String toList(
+ List<Map.Entry<String, Provider<? extends FileSystemLocation>>> patches) {
if (patches.isEmpty()) {
return " [empty]";
}
return patches.stream()
- .map(e -> " " + e.getKey() + "=" + e.getValue().get())
+ .map(e -> " " + e.getKey() + "=" + e.getValue().get().getAsFile())
.collect(Collectors.joining("\n"));
}
- public void logCompilationPaths(Logger logger) {
- String value =
- "Modular extension, compilation paths, source set="
- + (sourceSet.getName() + (hasModuleDescriptor() ? " (module)" : ""))
- + (", mode=" + mode + ":\n")
- + (" Module path:" + toList(getCompilationModulePath()) + "\n")
- + (" Class path: " + toList(getCompilationClasspath()) + "\n")
- + (" Patches: " + toList(modulePatches));
- if (debugPaths) {
- logger.lifecycle(value);
- } else {
- logger.info(value);
- }
+ public String getCompilationPathDebugInfo() {
+ return "Modular extension, compilation paths, source set="
+ + (sourceSet.getName() + (hasModuleDescriptor ? " (module)" : ""))
+ + (", mode=" + mode + ":\n")
+ + (" Module path:" + toList(getCompilationModulePath()) + "\n")
+ + (" Class path: " + toList(getCompilationClasspath()) + "\n")
+ + (" Patches: " + toList(modulePatches));
}
- public void logRuntimePaths(Logger logger) {
- String value =
- "Modular extension, runtime paths, source set="
- + (sourceSet.getName() + (hasModuleDescriptor() ? " (module)" : ""))
- + (", mode=" + mode + ":\n")
- + (" Module path:" + toList(getRuntimeModulePath()) + "\n")
- + (" Class path: " + toList(getRuntimeClasspath()) + "\n")
- + (" Patches : " + toList(modulePatches));
- if (debugPaths) {
- logger.lifecycle(value);
- } else {
- logger.info(value);
- }
+ public String getRuntimePathDebugInfo() {
+ return "Modular extension, runtime paths, source set="
+ + (sourceSet.getName() + (hasModuleDescriptor ? " (module)" : ""))
+ + (", mode=" + mode + ":\n")
+ + (" Module path:" + toList(getRuntimeModulePath()) + "\n")
+ + (" Class path: " + toList(getRuntimeClasspath()) + "\n")
+ + (" Patches : " + toList(modulePatches));
}
@Override
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ModularPathsPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ModularPathsPlugin.java
index bc45ed6eb99..da87e38e4e2 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ModularPathsPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ModularPathsPlugin.java
@@ -24,13 +24,14 @@ import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
-import org.gradle.api.Action;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginExtension;
+import org.gradle.api.provider.ListProperty;
+import org.gradle.api.provider.Property;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.bundling.Jar;
@@ -120,7 +121,16 @@ public class ModularPathsPlugin extends LuceneGradlePlugin {
task.setClasspath(modularPaths.getCompilationClasspath());
}
- task.doFirst(t -> modularPaths.logCompilationPaths(t.getLogger()));
+ Property<String> debugInfo =
+ project
+ .getObjects()
+ .property(String.class)
+ .convention(
+ project
+ .getProviders()
+ .provider(modularPaths::getCompilationPathDebugInfo));
+
+ task.doFirst(t -> t.getLogger().info(debugInfo.get()));
});
// For source sets that contain a module descriptor, configure a jar task that
@@ -161,10 +171,10 @@ public class ModularPathsPlugin extends LuceneGradlePlugin {
boolean mainIsEmpty = main.getAllJava().isEmpty();
boolean mainIsModular =
((ModularPathsExtension) main.getExtensions().getByName(MODULAR_PATHS_EXTENSION_NAME))
- .hasModuleDescriptor();
+ .hasModuleDescriptor;
boolean testIsModular =
((ModularPathsExtension) test.getExtensions().getByName(MODULAR_PATHS_EXTENSION_NAME))
- .hasModuleDescriptor();
+ .hasModuleDescriptor;
// LUCENE-10304: if we modify the classpath here, IntelliJ no longer sees the dependencies as
// compile-time dependencies, don't know why.
@@ -232,76 +242,11 @@ public class ModularPathsPlugin extends LuceneGradlePlugin {
}
}
- //
- // Configures a Test task associated with the provided source set to use module paths.
- //
- // There is no explicit connection between source sets and test tasks so there is no way (?)
- // to do this automatically, convention-style.
- //
- // This closure can be used to configure a different task, with a different source set, should
- // we
- // have the need for it.
- Action<Test> configureTestTaskForSourceSet =
- task -> {
- // Default: configure for SourceSet 'test'. You can call this for other pairs if needed.
- SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
-
- File forkProperties = new File(task.getTemporaryDir(), "jvm-forking.properties");
-
- ModularPathsExtension modularPaths =
- ((ModularPathsExtension)
- testSourceSet.getExtensions().getByName(MODULAR_PATHS_EXTENSION_NAME));
- task.dependsOn(modularPaths);
-
- // Add modular dependencies (and transitives) to module path.
- task.getJvmArgumentProviders().add(modularPaths.getRuntimeArguments());
-
- // Modify default classpath for tests.
- task.setClasspath(modularPaths.getTestRuntimeClasspath());
-
- task.doFirst(t -> modularPaths.logRuntimePaths(t.getLogger()));
-
- // Pass all the required properties for tests which fork the JVM. We don't use
- // regular system properties here because this could affect task up-to-date checks.
- task.getJvmArgumentProviders()
- .add(() -> List.of("-Dtests.jvmForkArgsFile=" + forkProperties.getAbsolutePath()));
-
- // Before execution: compute full JVM args to be used by forked processes
- // and persist to file.
- task.doFirst(
- _ -> {
- // Start with runtime module-path args
- List<String> args = new ArrayList<>();
- modularPaths.getRuntimeArguments().asArguments().forEach(args::add);
-
- String cp = modularPaths.getRuntimeClasspath().getAsPath();
- if (!cp.isBlank()) {
- args.add("-cp");
- args.add(cp);
- }
-
- // Sanity check: no newlines in individual args
- for (String s : args) {
- if (s.contains("\n")) {
- throw new GradleException("LF in a forked jvm property?: " + s);
- }
- }
-
- try {
- Files.createDirectories(forkProperties.toPath().getParent());
- Files.writeString(forkProperties.toPath(), String.join("\n", args));
- } catch (IOException e) {
- throw new GradleException(
- "Failed to write fork properties file: " + forkProperties, e);
- }
- });
- };
-
project
.getTasks()
.withType(Test.class)
.matching(it -> it.getName().matches("test(_[0-9]+)?"))
- .configureEach(configureTestTaskForSourceSet);
+ .configureEach(t -> configureTestTaskForSourceSet(t, sourceSets));
// Configure module versions.
project
@@ -326,4 +271,85 @@ public class ModularPathsPlugin extends LuceneGradlePlugin {
task.getOptions().getJavaModuleVersion().set(projectVersion);
});
}
+
+ /**
+ * Configures the {@link Test} task associated with the provided source set to use module paths.
+ *
+ * <p>There is no explicit connection between source sets and test tasks so there is no way (?) to
+ * do this automatically, convention-style.
+ *
+ * <p>This closure can be used to configure a different task, with a different source set, should
+ * we have the need for it.
+ */
+ private void configureTestTaskForSourceSet(Test task, SourceSetContainer sourceSets) {
+ var project = task.getProject();
+
+ // Default: configure for SourceSet 'test'. You can call this for other pairs if needed.
+ SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
+
+ ModularPathsExtension modularPaths =
+ ((ModularPathsExtension)
+ testSourceSet.getExtensions().getByName(MODULAR_PATHS_EXTENSION_NAME));
+ task.dependsOn(modularPaths);
+
+ // Add modular dependencies (and transitives) to module path.
+ task.getJvmArgumentProviders().add(modularPaths.getRuntimeArguments());
+
+ // Modify default classpath for tests.
+ task.setClasspath(modularPaths.getTestRuntimeClasspath());
+
+ // Pass all the required properties for tests which fork the JVM. We don't use
+ // regular system properties here because this could affect task up-to-date checks.
+ File forkProperties = new File(task.getTemporaryDir(), "jvm-forking.properties");
+ task.getJvmArgumentProviders()
+ .add(() -> List.of("-Dtests.jvmForkArgsFile=" + forkProperties.getAbsolutePath()));
+
+ // Before execution: compute full JVM args list to be used by forked processes
+ // and persist to file.
+ ListProperty<String> jvmArgsProperty =
+ project
+ .getObjects()
+ .listProperty(String.class)
+ .value(
+ project
+ .getProviders()
+ .provider(
+ () -> {
+ List<String> args = new ArrayList<>();
+
+ // Start with runtime module-path args
+ modularPaths.getRuntimeArguments().asArguments().forEach(args::add);
+
+ String cp = modularPaths.getRuntimeClasspath().getAsPath();
+ if (!cp.isBlank()) {
+ args.add("-cp");
+ args.add(cp);
+ }
+
+ // Sanity check: no newlines in individual args
+ for (String s : args) {
+ if (s.contains("\n")) {
+ throw new GradleException("LF in a forked jvm property?: " + s);
+ }
+ }
+
+ return args;
+ }));
+ task.doFirst(
+ _ -> {
+ try {
+ Files.createDirectories(forkProperties.toPath().getParent());
+ Files.writeString(forkProperties.toPath(), String.join("\n", jvmArgsProperty.get()));
+ } catch (IOException e) {
+ throw new GradleException("Failed to write fork properties file: " + forkProperties, e);
+ }
+ });
+
+ Property<String> debugInfo =
+ project
+ .getObjects()
+ .property(String.class)
+ .convention(project.getProviders().provider(modularPaths::getRuntimePathDebugInfo));
+ task.doFirst(t -> t.getLogger().info(debugInfo.get()));
+ }
}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/TestsAndRandomizationPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/TestsAndRandomizationPlugin.java
index 1906f4ca20c..14edb234757 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/TestsAndRandomizationPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/TestsAndRandomizationPlugin.java
@@ -38,10 +38,12 @@ import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.invocation.Gradle;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.provider.Provider;
+import org.gradle.api.tasks.Delete;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
+import org.gradle.api.tasks.TaskContainer;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.api.tasks.testing.Test;
import org.gradle.api.tasks.testing.logging.TestExceptionFormat;
@@ -91,12 +93,14 @@ public class TestsAndRandomizationPlugin extends LuceneGradlePlugin {
BuildOptionsPlugin.LOCAL_BUILD_OPTIONS_FILE + " file";
};
+ var seedValueProvider = testsSeedOption.asStringProvider();
+
task.doFirst(
t -> {
t.getLogger()
.lifecycle(
"Running tests with root randomization seed tests.seed="
- + testsSeedOption.asStringProvider().get()
+ + seedValueProvider.get()
+ ", source: "
+ seedSource);
});
@@ -351,10 +355,11 @@ public class TestsAndRandomizationPlugin extends LuceneGradlePlugin {
boolean incubatorJavaVersion =
Set.of("21", "22", "23", "24", "25").contains(runtimeJava.getMajorVersion());
+ TaskContainer tasks = project.getTasks();
+
// if the vector module is in incubator, pass lint flags to suppress excessive warnings.
if (incubatorJavaVersion) {
- project
- .getTasks()
+ tasks
.withType(JavaCompile.class)
.configureEach(
task -> {
@@ -362,14 +367,33 @@ public class TestsAndRandomizationPlugin extends LuceneGradlePlugin {
});
}
- project
- .getTasks()
+ var wipeOutputsTask =
+ tasks.register(
+ "cleanTestOutputs",
+ Delete.class,
+ t -> {
+ for (var testTask : tasks.withType(Test.class)) {
+ t.delete(
+ testTask
+ .getReports()
+ .getJunitXml()
+ .getOutputLocation()
+ .dir("outputs")
+ .get()
+ .getAsFile());
+ }
+ });
+
+ tasks
.withType(Test.class)
.configureEach(
task -> {
// Running any test task should first display the root randomization seed.
task.dependsOn(":showTestsSeed");
+ // Wipe any existing outputs before we run.
+ task.dependsOn(wipeOutputsTask);
+
File testOutputsDir =
task.getReports()
.getJunitXml()
@@ -513,12 +537,6 @@ public class TestsAndRandomizationPlugin extends LuceneGradlePlugin {
task.include("**/Test*.class");
task.exclude("**/*$*");
- // Set up custom test output handler.
- task.doFirst(
- _ -> {
- project.delete(testOutputsDir);
- });
-
var spillDir = task.getTemporaryDir().toPath();
var listener =
new ErrorReportingTestListener(
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.java
index 26a1cde5eb9..719432bdc52 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.java
@@ -72,10 +72,11 @@ public class HelpPlugin extends LuceneGradlePlugin {
task -> {
task.setGroup("Help (developer guides and hints)");
task.setDescription(helpEntry.description);
+ var helpFilePath = rootProject.file(helpEntry.path).toPath();
task.doFirst(
_ -> {
try {
- println("\n" + Files.readString(rootProject.file(helpEntry.path).toPath()));
+ println("\n" + Files.readString(helpFilePath));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@@ -88,12 +89,15 @@ public class HelpPlugin extends LuceneGradlePlugin {
.named("help")
.configure(
task -> {
+ Object version = rootProject.getVersion();
+ String gradleVersion = rootProject.getGradle().getGradleVersion();
+
task.doFirst(
_ -> {
printf("");
printf(
"This is Lucene %s build file (gradle %s). See some guidelines in files",
- rootProject.getVersion(), rootProject.getGradle().getGradleVersion());
+ version, gradleVersion);
printf("found under the help/* folder or type any of these:");
printf("");
diff --git a/lucene/spatial-extras/build.gradle b/lucene/spatial-extras/build.gradle
index b40c270fc13..4ed0eef34ae 100644
--- a/lucene/spatial-extras/build.gradle
+++ b/lucene/spatial-extras/build.gradle
@@ -42,5 +42,5 @@ dependencies {
}
sourceSets.test.extensions.configure("modularPaths", {
- it.patchModule("spatial4j", project.providers.provider({ configurations.spatial4jTestPatch.singleFile }))
+ it.patchModule("spatial4j", configurations.spatial4jTestPatch)
})