LUCENE-9871: move dummy outputs aspect into a separate file.

This commit is contained in:
Dawid Weiss 2021-03-30 20:15:55 +02:00
parent 10520185a9
commit 32e891c60f
6 changed files with 42 additions and 24 deletions

View File

@ -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')

View File

@ -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 ->

View File

@ -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)
}
}

View File

@ -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()

View File

@ -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)

View File

@ -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}"