|
| 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 | +} |
0 commit comments