2022-10-02 12:11:06 +02:00
|
|
|
import dev.adamko.gradle.factorio.FactorioModPlugin
|
2022-09-18 20:49:32 +02:00
|
|
|
import kafkatorio.tasks.ProcessRunningSpec
|
2022-04-24 21:01:16 +02:00
|
|
|
import org.gradle.kotlin.dsl.support.serviceOf
|
2021-12-01 16:57:46 +01:00
|
|
|
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
|
|
|
|
|
|
|
|
|
plugins {
|
2022-09-18 20:49:32 +02:00
|
|
|
id("kafkatorio.conventions.infra.process-runner")
|
2022-10-02 12:11:06 +02:00
|
|
|
id("dev.adamko.factorio-mod")
|
2021-12-01 16:57:46 +01:00
|
|
|
}
|
|
|
|
|
|
2022-12-19 16:53:18 +01:00
|
|
|
description = "Manage the Factorio game client"
|
2021-12-28 17:05:52 +01:00
|
|
|
|
2022-06-23 23:59:48 +02:00
|
|
|
val clientModsDirectory: DirectoryProperty = objects.directoryProperty().apply {
|
|
|
|
|
val modDir = File("""D:\Users\Adam\AppData\Roaming\Factorio\mods""")
|
|
|
|
|
if (modDir.exists()) {
|
|
|
|
|
set(modDir)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-01 16:57:46 +01:00
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
|
factorioMod(projects.modules.eventsMod)
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-26 14:56:53 +02:00
|
|
|
|
2022-04-24 21:01:16 +02:00
|
|
|
fun ExecOperations.isFactorioRunning(): Spec<Task> = ProcessRunningSpec(this, "factorio.exe")
|
|
|
|
|
|
2021-12-01 16:57:46 +01:00
|
|
|
|
|
|
|
|
val clientKill by tasks.registering(Exec::class) {
|
2022-06-26 14:56:53 +02:00
|
|
|
description = "Stop the local Factorio Steam game client"
|
2022-10-02 12:11:06 +02:00
|
|
|
group = FactorioModPlugin.TASK_GROUP
|
2022-04-24 21:01:16 +02:00
|
|
|
|
|
|
|
|
onlyIf(serviceOf<ExecOperations>().isFactorioRunning())
|
|
|
|
|
|
2021-12-01 16:57:46 +01:00
|
|
|
commandLine = parseSpaceSeparatedArgs(""" taskkill /im factorio.exe """)
|
|
|
|
|
doFirst { logger.lifecycle("Killing factorio.exe") }
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-26 14:56:53 +02:00
|
|
|
|
2022-10-02 12:11:06 +02:00
|
|
|
tasks.register(FactorioModPlugin.PUBLISH_MOD_LOCAL_TASK_NAME) {
|
|
|
|
|
group = FactorioModPlugin.TASK_GROUP
|
2022-12-18 01:40:40 +01:00
|
|
|
// dependsOn(deployModToLocalClient)
|
2022-06-26 14:56:53 +02:00
|
|
|
}
|
|
|
|
|
|
2021-12-01 16:57:46 +01:00
|
|
|
|
|
|
|
|
tasks.processRun {
|
|
|
|
|
dependsOn(
|
2022-12-18 01:40:40 +01:00
|
|
|
// deployModToLocalClient,
|
|
|
|
|
tasks.launchFactorioClient,
|
2021-12-01 16:57:46 +01:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tasks.processKill {
|
|
|
|
|
dependsOn(clientKill)
|
|
|
|
|
}
|
2022-09-13 17:56:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
val runFactorioClient by tasks.registering {
|
|
|
|
|
group = rootProject.name
|
|
|
|
|
|
|
|
|
|
dependsOn(tasks.processRun)
|
|
|
|
|
}
|