2022-01-09 18:48:32 +01:00
|
|
|
import org.jetbrains.kotlin.incremental.md5
|
2021-12-26 22:55:06 +01:00
|
|
|
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
|
|
|
|
|
2021-12-01 16:57:46 +01:00
|
|
|
plugins {
|
2022-03-09 21:40:40 +01:00
|
|
|
dev.adamko.kafkatorio.infra.`docker-compose`
|
2021-12-01 16:57:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
description = "Send events from a Factorio server to a Kafka topic "
|
|
|
|
|
|
2021-12-26 22:55:06 +01:00
|
|
|
|
|
|
|
|
val dockerSrcDir: Directory by extra
|
2022-01-09 18:48:32 +01:00
|
|
|
fun Directory.filesChecksum() = asFileTree
|
|
|
|
|
.files
|
|
|
|
|
.map { it.readBytes() + it.absolutePath.toByteArray() }
|
|
|
|
|
.fold(byteArrayOf()) { acc, bytes -> acc + bytes }
|
|
|
|
|
.md5()
|
2021-12-26 22:55:06 +01:00
|
|
|
|
2021-12-02 00:54:15 +01:00
|
|
|
tasks.dockerUp {
|
|
|
|
|
dependsOn(":modules:infra-kafka-cluster:dockerUp")
|
|
|
|
|
}
|
2021-12-26 22:55:06 +01:00
|
|
|
|
|
|
|
|
val dockerBuildKafkaPipe by tasks.registering(Exec::class) {
|
|
|
|
|
group = "docker-compose"
|
|
|
|
|
|
|
|
|
|
logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
|
|
|
|
|
|
|
|
|
dependsOn(tasks.dockerEnv)
|
|
|
|
|
|
|
|
|
|
inputs.dir(dockerSrcDir)
|
2022-01-09 18:48:32 +01:00
|
|
|
inputs.property("dockerSrcDirChecksum") { dockerSrcDir.filesChecksum() }
|
2021-12-26 22:55:06 +01:00
|
|
|
|
2022-01-09 18:48:32 +01:00
|
|
|
outputs.upToDateWhen {
|
|
|
|
|
it.inputs.properties["dockerSrcDirChecksum"] as? Long? == dockerSrcDir.filesChecksum()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// val imageIdFile = file("$temporaryDir/docker-image-id.txt")
|
|
|
|
|
// outputs.file(imageIdFile)
|
2022-01-09 18:05:28 +01:00
|
|
|
|
2021-12-26 22:55:06 +01:00
|
|
|
workingDir = dockerSrcDir.asFile
|
|
|
|
|
commandLine = parseSpaceSeparatedArgs(""" docker-compose build kafka-pipe """)
|
2022-01-09 18:05:28 +01:00
|
|
|
|
2022-01-09 18:48:32 +01:00
|
|
|
// doLast {
|
|
|
|
|
// sync {
|
|
|
|
|
// from(dockerSrcDir)
|
|
|
|
|
// into(temporaryDir)
|
|
|
|
|
// }
|
|
|
|
|
// imageIdFile.outputStream().use { os ->
|
|
|
|
|
// exec {
|
|
|
|
|
// workingDir = dockerSrcDir.asFile
|
|
|
|
|
// commandLine = parseSpaceSeparatedArgs(""" docker-compose images -q kafka-pipe """)
|
|
|
|
|
// standardOutput = os
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2021-12-26 22:55:06 +01:00
|
|
|
}
|
2022-01-09 18:05:28 +01:00
|
|
|
tasks.assemble { dependsOn(dockerBuildKafkaPipe) }
|