Update timestamps of test report if running on ci

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.
This commit is contained in:
Sebastian Sdorra
2021-01-13 15:37:57 +01:00
committed by René Pfeuffer
parent 22375c8096
commit 4e1bf1d13b
12 changed files with 105 additions and 12 deletions

View File

@@ -0,0 +1,46 @@
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)
}
}
}