forked from gradle/kotlin-dsl-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
30 lines (26 loc) · 1.01 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import org.gradle.internal.hash.HashUtil
plugins {
base
}
tasks {
val samplesWrappers by registering {
doLast {
val wrapperFiles = wrapper.get().run {
listOf(scriptFile, batchScript, jarFile, propertiesFile).associateBy { it.name }
}
val hashes = wrapperFiles.mapValues { HashUtil.sha256(it.value) }
file("samples").walk().filter { it.isFile && it.name in wrapperFiles }.forEach { sampleWrapperFile ->
wrapperFiles.getValue(sampleWrapperFile.name).let { wrapperFile ->
if (HashUtil.sha256(sampleWrapperFile) != hashes.getValue(sampleWrapperFile.name)) {
logger.lifecycle("Updating ${sampleWrapperFile.relativeTo(rootDir)}")
wrapperFile.copyTo(sampleWrapperFile, overwrite = true)
}
}
}
}
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
finalizedBy(samplesWrappers)
}
}