Apache Lucene open-source search software
LUCENE-9871: move dummy outputs aspect into a separate file.
Dawid Weiss32e891c60fd5
diff --git a/build.gradle b/build.gradleindex e50b1b70b6d..648c419b985 100644--- a/build.gradle+++ b/build.gradle@@ -177,3 +177,4 @@ apply from: file('gradle/hacks/gradle-archives.gradle')apply from: file('gradle/hacks/wipe-temp.gradle')apply from: file('gradle/hacks/hashmapAssertions.gradle')apply from: file('gradle/hacks/turbocharge-jvm-opts.gradle')+apply from: file('gradle/hacks/dummy-outputs.gradle')diff --git a/gradle/globals.gradle b/gradle/globals.gradleindex fbcbb2dd30c..66b16605e8a 100644--- a/gradle/globals.gradle+++ b/gradle/globals.gradle@@ -61,18 +61,6 @@ allprojects {return file(buildscript.sourceFile.absolutePath.replaceAll('.gradle$', ""))}- // LUCENE-9505: utility function that sets up dummy outputs for a task so that- // clean[TaskName] works and allows selective re-runs.- setupDummyOutputs = { Task task ->- File dummyOutput = file("${task.project.buildDir}/tasks/${task.name}/dummy-output.txt")- task.outputs.file(dummyOutput)- task.doLast {- if (!dummyOutput.exists()) {- dummyOutput.createNewFile()- }- }- }-// Utility function similar to project.exec but not emitting// any output unless an error code is returned from the executed command.quietExec = { closure ->diff --git a/gradle/hacks/dummy-outputs.gradle b/gradle/hacks/dummy-outputs.gradlenew file mode 100644index 00000000000..1d9a1541a05--- /dev/null+++ b/gradle/hacks/dummy-outputs.gradle@@ -0,0 +1,41 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++// LUCENE-9505: utility function that sets up dummy outputs for a task so that+// clean[TaskName] works and allows selective re-runs.++def setupDummyOutputs = { Task task ->+ File dummyOutput = file("${task.project.buildDir}/tasks/${task.name}/dummy-output.txt")+ task.outputs.file(dummyOutput)+ task.doLast {+ if (!dummyOutput.exists()) {+ dummyOutput.createNewFile()+ }+ }+}++allprojects {+ tasks.matching {+ it.name.startsWith("ecjLint") ||+ it.name in [+ "gradlewScriptsTweaked",+ "validateSourcePatterns"+ ] }.all { Task task ->+ task.logger.info("Setting up ${task.path} as no-output.")+ setupDummyOutputs(task)+ }+}diff --git a/gradle/validation/ecj-lint.gradle b/gradle/validation/ecj-lint.gradleindex 7b6415703b9..8c72f9d30f9 100644--- a/gradle/validation/ecj-lint.gradle+++ b/gradle/validation/ecj-lint.gradle@@ -47,9 +47,6 @@ allprojects {// The inputs are all source files from the sourceSet.inputs.files sourceSet.allSource.asFileTree- // This task has no proper outputs.- setupDummyOutputs(task)-// We create a task for all source sets but ignore those// that don't have any Java source directories.enabled = !srcDirs.isEmpty()diff --git a/gradle/validation/gradlew-scripts-tweaked.gradle b/gradle/validation/gradlew-scripts-tweaked.gradleindex fa3ba6d883e..a37d4e52b13 100644--- a/gradle/validation/gradlew-scripts-tweaked.gradle+++ b/gradle/validation/gradlew-scripts-tweaked.gradle@@ -29,9 +29,6 @@ configure(rootProject) {inputs.files(scripts)- // This task has no proper outputs.- setupDummyOutputs(task)-doFirst {scripts.each { file ->def content = new String(file.readBytes(), StandardCharsets.US_ASCII)diff --git a/gradle/validation/validate-source-patterns.gradle b/gradle/validation/validate-source-patterns.gradleindex 9ac74e1c112..389ca740c8b 100644--- a/gradle/validation/validate-source-patterns.gradle+++ b/gradle/validation/validate-source-patterns.gradle@@ -66,9 +66,6 @@ subprojects {group = 'Verification'description = 'Validate Source Patterns'- // This task has no proper outputs.- setupDummyOutputs(task)-sourceFiles = fileTree(projectDir) {extensions.each{include "**/*.${it}"@@ -99,9 +96,6 @@ configure(rootProject) {group = 'Verification'description = 'Validate Source Patterns'- // This task has no proper outputs.- setupDummyOutputs(task)-sourceFiles = fileTree(projectDir) {extensions.each{include "**/*.${it}"