mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-03 03:55:51 +01:00
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:
committed by
René Pfeuffer
parent
22375c8096
commit
4e1bf1d13b
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user