Skip to content

Commit f835874

Browse files
authored
Add logical test option groups for the allOptions task. (#14795)
1 parent 52fb6eb commit f835874

File tree

4 files changed

+85
-5
lines changed

4 files changed

+85
-5
lines changed

build-tools/build-infra/src/main/groovy/lucene.all-projects.conventions.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ allprojects {project ->
2525
// All projects have the base plugin (convention tasks like 'check', etc.)
2626
apply plugin: 'base'
2727

28+
// Configure build option groups.
29+
project.plugins.apply(org.apache.lucene.gradle.plugins.help.BuildOptionGroupsPlugin)
30+
2831
// Project group and version.
2932
group = "org.apache.lucene"
3033
version = rootProject.version

build-tools/build-infra/src/main/groovy/lucene.help.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ tasks.named("help").configure {
108108
}
109109

110110
println ""
111-
println "For the impatient, build the project with 'gradlew assemble', run all tests with 'gradlew check'."
111+
println "For the impatient, build the project with 'gradlew assemble', run all tests with 'gradlew check', check " +
112+
"your current build options with 'gradlew allOptions'."
112113
throw new StopExecutionException()
113114
}
114115
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package org.apache.lucene.gradle.plugins.help;
2+
3+
import com.carrotsearch.gradle.buildinfra.buildoptions.BuildOptionsTask;
4+
import java.util.regex.Pattern;
5+
import java.util.stream.Collectors;
6+
import java.util.stream.Stream;
7+
import org.gradle.api.Plugin;
8+
import org.gradle.api.Project;
9+
10+
/** Group related Lucene build options into higher level categories. */
11+
public class BuildOptionGroupsPlugin implements Plugin<Project> {
12+
@Override
13+
public void apply(Project project) {
14+
project
15+
.getTasks()
16+
.withType(BuildOptionsTask.class)
17+
.configureEach(
18+
task -> {
19+
task.optionGroups(
20+
optionGroups -> {
21+
optionGroups.group("Lucene version strings", "version\\.(.*)");
22+
23+
optionGroups.group("IDE-tweaking options", "eclipse\\.(.+)");
24+
25+
optionGroups.group(
26+
"Optional testing and test resources",
27+
explicitList(
28+
"tests.hunspell.regressions",
29+
"validation.errorprone",
30+
"hunspell.corpora",
31+
"hunspell.dictionaries",
32+
"hunspell.repo.path",
33+
"validation.owasp",
34+
"validation.owasp.apikey",
35+
"validation.owasp.threshold"));
36+
37+
optionGroups.group("Test profiling", "tests\\.profile\\.(.*)");
38+
39+
optionGroups.group(
40+
"Test repetition control",
41+
explicitList("tests.iters", "tests.dups", "tests.failfast"));
42+
43+
optionGroups.group(
44+
"Test randomization and all test-related options", "tests\\.(.*)");
45+
46+
optionGroups.group(
47+
"Local tool paths",
48+
"(lucene\\.tool\\.(.*))|" + explicitList("runtime.java.home"));
49+
50+
optionGroups.group(
51+
"Options configuring the :lucene:benchmark:run task",
52+
explicitList("maxHeapSize", "standardOutput", "taskAlg"));
53+
54+
optionGroups.group(
55+
"Options useful for release managers",
56+
explicitList("lucene.javadoc.url", "sign", "useGpg"));
57+
58+
optionGroups.group(
59+
"Build control and information",
60+
explicitList(
61+
"task.times",
62+
"javac.failOnWarnings",
63+
"tests.slowestSuites",
64+
"tests.slowestSuites.minTime",
65+
"tests.slowestTests",
66+
"tests.slowestTests.minTime"));
67+
});
68+
});
69+
}
70+
71+
private static String explicitList(String... explicitOptions) {
72+
return Stream.of(explicitOptions)
73+
.map(opt -> "(" + Pattern.quote(opt) + ")")
74+
.collect(Collectors.joining("|"));
75+
}
76+
}

help/localSettings.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ coverage or profiling).
1717

1818
To see the current values of all these options, run:
1919

20-
./gradlew buildOptions
20+
./gradlew allOptions
2121

22-
this prints all build options for each module. You can also scope
23-
this task to just one module, for example:
22+
this prints all build options for all modules. You can print all options
23+
for a single module too, for example:
2424

2525
./gradlew -p lucene/core buildOptions
2626

27-
The output of this task shows all options, their current values
27+
The output of both tasks shows the options, their current values
2828
and their current value's "source". All build option values can be
2929
overridden by, in order of priority:
3030

0 commit comments

Comments
 (0)