Apache Lucene open-source search software
Allow turning off gradle/groovy script spotless pass using 'lucene.spotlessGradleScripts' build option (#14791)
Dawid Weiss9238ca74a12f
diff --git a/build-tools/build-infra/src/main/groovy/lucene.validation.spotless-groovy.gradle b/build-tools/build-infra/src/main/groovy/lucene.validation.spotless-groovy.gradleindex 664650dfb1c..e5c5132c956 100644--- a/build-tools/build-infra/src/main/groovy/lucene.validation.spotless-groovy.gradle+++ b/build-tools/build-infra/src/main/groovy/lucene.validation.spotless-groovy.gradle@@ -27,17 +27,39 @@ if (project != project.rootProject) {plugins.apply(SpotlessPlugin.class)-spotless.format("gradleScripts", GroovyGradleExtension.class, { ext ->- ext.greclipse()- ext.leadingTabsToSpaces(2)- ext.trimTrailingWhitespace()- ext.endWithNewline()- ext.target([- "build-tools/**/*.gradle",- "build-tools/**/*.groovy",- "**/build.gradle"- ])-})+def spotlessGradleScriptsOptionName = "lucene.spotlessGradleScripts"+Provider<Boolean> spotlessGradleScriptsOption = buildOptions.addBooleanOption(spotlessGradleScriptsOptionName,+ "Enable formatting and validation of groovy/gradle scripts (you may want to turn it off locally on slow" ++ " networks or computers)", true)++if (!spotlessGradleScriptsOption.get()) {+ // register empty stubs for the corresponding set of spotless tasks.+ [+ "spotlessGradleScripts",+ "spotlessGradleScriptsApply",+ "spotlessGradleScriptsCheck"+ ].each {taskName ->+ tasks.register(taskName, {+ doFirst {+ logger.warn("You requested spotless to be locally turned off for gradle/groovy scripts. CI " ++ "checks may not pass if you have formatting " ++ "differences ('${spotlessGradleScriptsOptionName}' build option is set to false).")+ }+ })+ }+} else {+ spotless.format("gradleScripts", GroovyGradleExtension.class, { ext ->+ ext.greclipse()+ ext.leadingTabsToSpaces(2)+ ext.trimTrailingWhitespace()+ ext.endWithNewline()+ ext.target([+ "build-tools/**/*.gradle",+ "build-tools/**/*.groovy",+ "**/build.gradle"+ ])+ })+}tasks.named("spotlessGradleScripts").configure {mustRunAfter ":lucene:build-tools:missing-doclet:spotlessJava"diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/help/BuildOptionGroupsPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/help/BuildOptionGroupsPlugin.javaindex 78d488c501e..444fbe196d7 100644--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/help/BuildOptionGroupsPlugin.java+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/help/BuildOptionGroupsPlugin.java@@ -58,6 +58,7 @@ public class BuildOptionGroupsPlugin implements Plugin<Project> {optionGroups.group("Build control and information",explicitList(+ "lucene.spotlessGradleScripts","task.times","javac.failOnWarnings","tests.slowestSuites",diff --git a/help/formatting.txt b/help/formatting.txtindex 5b18c9fbe73..137d371efea 100644--- a/help/formatting.txt+++ b/help/formatting.txt@@ -18,3 +18,14 @@ majority of cases the formatter will do a great job of cleaning up thecode. Occasionally you may want to rewrite the code (introduce a localvariable or reshape code paths) so that it's easier to read afterautomatic formatting.++Gradle scripts+==============++Groovy and gradle code is also automatically formatted and this formatting+is enforced. This is unfortunately a heavy download and runtime-costly+application. If you'd like to temporarily skip this validation step, set+the lucene.spotlessGradleScripts option to false - either on command line+using -Plucene.spotlessGradleScripts=false, in your local+build-options.local.properties or by any other means build options can be+set.\ No newline at end of file