Refactor: project renaming, using improved build dsl

This commit is contained in:
Ilya Chernikov
2017-09-11 14:47:07 +02:00
parent 8e24383428
commit b6c255cea5
24 changed files with 209 additions and 217 deletions
+8 -9
View File
@@ -3,18 +3,16 @@ import java.io.File
val buildVersionFilePath = "${rootProject.extra["distDir"]}/build.txt"
val mainCfg = configurations.create("default")
val buildVersion by configurations.creating
artifacts.add(mainCfg.name, file(buildVersionFilePath))
val mainTask = task("prepare") {
val prepare = task("prepare") {
val versionString = rootProject.extra["build.number"].toString()
val versionFile = File(buildVersionFilePath)
outputs.file(buildVersionFilePath)
outputs.upToDateWhen {
(versionFile.exists() && versionFile.readText().trim() == versionString).apply {
if (!this) {
println("!!! not up-to-date $versionFile: ${versionFile.takeIf { it.exists() }?.readText()?.trim()}")
(versionFile.exists() && versionFile.readText().trim() == versionString).also {
if (!it) {
logger.info("$versionFile is not up-to-date: ${versionFile.takeIf { it.exists() }?.readText()?.trim()}")
}
}
}
@@ -24,5 +22,6 @@ val mainTask = task("prepare") {
}
}
defaultTasks(mainTask.name)
artifacts.add(buildVersion.name, file(buildVersionFilePath)) {
builtBy(prepare)
}