mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-26 08:06:09 +01:00
We have to update the timestamps of our test reports on the ci server, because Jenkins fails it the reports are older than x minutes.
47 lines
841 B
Groovy
47 lines
841 B
Groovy
package com.cloudogu.scm
|
|
|
|
import org.gradle.api.DefaultTask
|
|
import org.gradle.api.tasks.Input
|
|
import org.gradle.api.tasks.InputDirectory
|
|
import org.gradle.api.tasks.TaskAction
|
|
|
|
import java.time.Instant
|
|
|
|
class TouchFilesTask extends DefaultTask {
|
|
|
|
@InputDirectory
|
|
File directory
|
|
|
|
@Input
|
|
String extension
|
|
|
|
@Input
|
|
long timestamp
|
|
|
|
TouchFilesTask() {
|
|
timestamp = Instant.now().toEpochMilli()
|
|
// this task should run always
|
|
outputs.upToDateWhen {
|
|
false
|
|
}
|
|
}
|
|
|
|
@TaskAction
|
|
public void execute() {
|
|
if (directory.exists()) {
|
|
touch(directory)
|
|
}
|
|
}
|
|
|
|
private void touch(File file) {
|
|
if (file.isDirectory()) {
|
|
for (File child : file.listFiles()) {
|
|
touch(child)
|
|
}
|
|
} else if (file.getName().endsWith(".${extension}")) {
|
|
file.setLastModified(timestamp)
|
|
}
|
|
}
|
|
|
|
}
|