Skip to content

Commit f124933

Browse files
committed
Review Feedback Vol. 2
1 parent 8b20aab commit f124933

3 files changed

Lines changed: 34 additions & 15 deletions

File tree

build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessGithubWorkflow.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.gradle.api.provider.Property
88
import org.gradle.api.provider.Provider
99
import org.gradle.api.tasks.*
1010
import org.gradle.jvm.toolchain.JavaLauncher
11+
import org.gradle.work.NormalizeLineEndings
1112
import org.gradle.workers.WorkerExecutor
1213

1314
import javax.inject.Inject
@@ -16,10 +17,12 @@ import javax.inject.Inject
1617
@CacheableTask
1718
abstract class PreprocessGithubWorkflow extends DefaultTask {
1819
@InputFile
20+
@NormalizeLineEndings
1921
@PathSensitive(PathSensitivity.RELATIVE)
2022
abstract RegularFileProperty getWorkflowScript()
2123

2224
@InputFiles
25+
@NormalizeLineEndings
2326
@PathSensitive(PathSensitivity.RELATIVE)
2427
abstract ConfigurableFileCollection getImportedFiles()
2528

build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessWorkflowsPlugin.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import groovy.transform.CompileStatic
2020
import org.gradle.api.Plugin
2121
import org.gradle.api.Project
2222
import org.gradle.api.artifacts.VersionCatalogsExtension
23+
import org.gradle.api.tasks.Delete
2324
import org.gradle.jvm.toolchain.JavaLanguageVersion
2425
import org.gradle.jvm.toolchain.JavaToolchainService
2526

@@ -62,6 +63,12 @@ class PreprocessWorkflowsPlugin implements Plugin<Project> {
6263
it.languageVersion.set(JavaLanguageVersion.of(17))
6364
})
6465
}
66+
def deleteWorkflowYaml = project.tasks.register("delete${pascalCasedWorkflowName}WorkflowYaml", Delete) {
67+
it.delete(preprocessWorkflow.flatMap { it.workflowFile })
68+
}
69+
preprocessWorkflow.configure {
70+
it.dependsOn(deleteWorkflowYaml)
71+
}
6572
project.pluginManager.withPlugin('io.spring.nohttp') {
6673
// iff both tasks are run, workflow files should be generated before checkstyle check
6774
project.tasks.named('checkstyleNohttp') {

build.gradle

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -405,30 +405,39 @@ def configureGroovydoc(TaskProvider groovydoc) {
405405
}
406406
}
407407

408-
tasks.preprocessBranchesAndPrsWorkflow {
409-
inputs.file('.github/codecov.yml').withPropertyName('codecovConfig')
410-
def preprocessBranchesAndPrsWorkflowCodecovOutput = layout.buildDirectory.file('codecov_branches-and-prs.yml')
411-
outputs.file(preprocessBranchesAndPrsWorkflowCodecovOutput).withPropertyName('codecovConfig')
408+
def preprocessBranchesAndPrsWorkflowCodecovOutput = layout.buildDirectory.file('codecov_branches-and-prs.yml')
409+
def preprocessReleaseWorkflowCodecovOutput = layout.buildDirectory.file('codecov_release.yml')
412410

411+
def copyCodecovConfig = tasks.register('copyCodecovConfig') {
413412
doLast {
414413
copy {
415-
from(preprocessBranchesAndPrsWorkflowCodecovOutput)
414+
from(
415+
[
416+
preprocessBranchesAndPrsWorkflowCodecovOutput,
417+
preprocessReleaseWorkflowCodecovOutput
418+
].max {it.get().asFile.lastModified() })
416419
into('.github')
417420
rename { 'codecov.yml' }
418421
}
419422
}
420423
}
421424

425+
tasks.preprocessBranchesAndPrsWorkflow {
426+
inputs
427+
.file('.github/codecov.yml')
428+
.normalizeLineEndings()
429+
.withPathSensitivity(PathSensitivity.RELATIVE)
430+
.withPropertyName('codecovConfig')
431+
outputs.file(preprocessBranchesAndPrsWorkflowCodecovOutput).withPropertyName('codecovConfig')
432+
finalizedBy(copyCodecovConfig)
433+
}
434+
422435
tasks.preprocessReleaseWorkflow {
423-
inputs.file('.github/codecov.yml').withPropertyName('codecovConfig')
424-
def preprocessReleaseWorkflowCodecovOutput = layout.buildDirectory.file('codecov_release.yml')
436+
inputs
437+
.file('.github/codecov.yml')
438+
.normalizeLineEndings()
439+
.withPathSensitivity(PathSensitivity.RELATIVE)
440+
.withPropertyName('codecovConfig')
425441
outputs.file(preprocessReleaseWorkflowCodecovOutput).withPropertyName('codecovConfig')
426-
427-
doLast {
428-
copy {
429-
from(preprocessReleaseWorkflowCodecovOutput)
430-
into('.github')
431-
rename { 'codecov.yml' }
432-
}
433-
}
442+
finalizedBy(copyCodecovConfig)
434443
}

0 commit comments

Comments
 (0)