2021-12-28 16:26:23 +01:00
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
2022-02-08 11:51:16 +01:00
|
|
|
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
2021-12-28 16:26:23 +01:00
|
|
|
|
2021-10-22 18:19:53 +02:00
|
|
|
plugins {
|
2022-01-16 23:16:09 +01:00
|
|
|
dev.adamko.kafkatorio.lang.`kotlin-jvm`
|
2021-10-25 23:35:47 +02:00
|
|
|
kotlin("plugin.serialization")
|
2021-10-24 14:55:04 +02:00
|
|
|
application
|
2021-10-22 18:19:53 +02:00
|
|
|
}
|
|
|
|
|
|
2021-12-01 13:35:32 +01:00
|
|
|
description = """
|
2021-10-22 18:19:53 +02:00
|
|
|
Receive raw Factorio Events from Kafka and process them into targeted topics or data formats.
|
|
|
|
|
|
|
|
|
|
Factorio events -> Mod -> Kafka -> ***Factorio Events Processor*** -> processed events
|
|
|
|
|
""".trimIndent()
|
|
|
|
|
|
|
|
|
|
val projectId: String by project.extra
|
|
|
|
|
|
2022-02-09 13:16:57 +01:00
|
|
|
|
2021-10-24 14:55:04 +02:00
|
|
|
dependencies {
|
|
|
|
|
|
2022-02-09 11:53:58 +01:00
|
|
|
implementation(libs.kafka.streams)
|
2021-10-24 14:55:04 +02:00
|
|
|
|
2021-12-01 16:57:46 +01:00
|
|
|
implementation(projects.modules.eventsSchema)
|
2021-12-01 13:35:32 +01:00
|
|
|
|
|
|
|
|
// implementation("com.ionspin.kotlin:bignum:0.3.3")
|
|
|
|
|
|
2021-12-27 12:44:37 +01:00
|
|
|
implementation(platform(libs.kotlinx.serialization.bom))
|
2021-12-01 13:35:32 +01:00
|
|
|
implementation(libs.kotlinx.serialization.core)
|
|
|
|
|
implementation(libs.kotlinx.serialization.json)
|
2022-01-21 18:31:15 +01:00
|
|
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf")
|
2021-10-25 23:35:47 +02:00
|
|
|
|
2021-12-27 12:44:37 +01:00
|
|
|
implementation(libs.kotlinx.coroutines)
|
|
|
|
|
|
2021-10-24 14:55:04 +02:00
|
|
|
implementation(platform(libs.http4k.bom))
|
2021-12-28 16:26:23 +01:00
|
|
|
implementation(libs.bundles.http4k)
|
2021-12-01 13:35:32 +01:00
|
|
|
implementation(libs.http4k.format.kotlinx)
|
2021-10-24 14:55:04 +02:00
|
|
|
|
|
|
|
|
implementation(libs.bundles.logging)
|
2022-01-13 00:00:59 +01:00
|
|
|
|
|
|
|
|
implementation("com.sksamuel.scrimage:scrimage-core:4.0.24")
|
2022-01-16 23:16:09 +01:00
|
|
|
|
2022-02-06 21:05:37 +01:00
|
|
|
val kotkaVersion = "v0.0.12"
|
|
|
|
|
// val kotkaVersion = "store-iterators-SNAPSHOT"
|
2022-01-16 23:16:09 +01:00
|
|
|
implementation("com.github.adamko-dev.kotka-streams:kotka-streams:$kotkaVersion") {
|
|
|
|
|
isChanging = true
|
|
|
|
|
}
|
|
|
|
|
// val kotkaVersion = "main-SNAPSHOT"
|
|
|
|
|
// implementation("dev.adamko.kotka:kotka-streams:$kotkaVersion") {
|
|
|
|
|
// isChanging = true
|
|
|
|
|
// }
|
|
|
|
|
|
2021-10-24 14:55:04 +02:00
|
|
|
}
|
|
|
|
|
|
2022-02-05 12:20:25 +01:00
|
|
|
//configurations.all {
|
|
|
|
|
// resolutionStrategy.cacheDynamicVersionsFor(1, TimeUnit.MINUTES)
|
|
|
|
|
//}
|
|
|
|
|
|
2021-10-24 14:55:04 +02:00
|
|
|
application {
|
2022-01-09 11:05:30 +01:00
|
|
|
mainClass.set("dev.adamko.kafkatorio.processor.EventProcessorKt")
|
2021-10-24 14:55:04 +02:00
|
|
|
}
|
2021-12-28 16:26:23 +01:00
|
|
|
|
|
|
|
|
tasks.withType<KotlinCompile> {
|
|
|
|
|
kotlinOptions.freeCompilerArgs += listOf(
|
|
|
|
|
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
2022-02-05 12:20:25 +01:00
|
|
|
"-opt-in=kotlinx.coroutines.FlowPreview",
|
2021-12-28 16:26:23 +01:00
|
|
|
)
|
|
|
|
|
}
|
2022-02-08 11:51:16 +01:00
|
|
|
|
2022-02-09 23:02:16 +01:00
|
|
|
val kafkatorioEventsServerKafkaForceReset by tasks.registering {
|
2022-02-08 11:51:16 +01:00
|
|
|
group = project.name
|
|
|
|
|
|
2022-02-09 23:02:16 +01:00
|
|
|
fun reset(applicationId: String) = """
|
|
|
|
|
/kafka/bin/kafka-streams-application-reset.sh --application-id $applicationId --force
|
2022-02-08 11:51:16 +01:00
|
|
|
""".trimIndent()
|
|
|
|
|
|
2022-02-09 23:02:16 +01:00
|
|
|
doLast {
|
|
|
|
|
|
|
|
|
|
exec {
|
|
|
|
|
val cmd = reset("kafkatorio-events-processor.saveTiles")
|
|
|
|
|
logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
|
|
|
|
commandLine = parseSpaceSeparatedArgs(""" docker exec -d kafka $cmd """)
|
|
|
|
|
}
|
|
|
|
|
exec {
|
|
|
|
|
val cmd = reset("kafkatorio-events-processor.splitPackets")
|
|
|
|
|
logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
|
|
|
|
commandLine = parseSpaceSeparatedArgs(""" docker exec -d kafka $cmd --input-topics factorio-server-log """)
|
|
|
|
|
}
|
|
|
|
|
exec {
|
|
|
|
|
val cmd = reset("kafkatorio-events-processor.playerUpdates")
|
|
|
|
|
logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
|
|
|
|
commandLine = parseSpaceSeparatedArgs(""" docker exec -d kafka $cmd """)
|
|
|
|
|
}
|
2022-02-09 23:38:12 +01:00
|
|
|
exec {
|
|
|
|
|
val cmd = reset("kafkatorio-events-processor.groupTilesMapChunks")
|
|
|
|
|
logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
|
|
|
|
commandLine = parseSpaceSeparatedArgs(""" docker exec -d kafka $cmd """)
|
|
|
|
|
}
|
2022-02-09 23:02:16 +01:00
|
|
|
}
|
2022-02-08 11:51:16 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-08 14:10:13 +01:00
|
|
|
//tasks.run.configure {
|
|
|
|
|
// dependsOn(kafkatorioEventsServerKafkaForceReset)
|
|
|
|
|
//}
|