- more tidying up
- setting up distribution plugin - using more variables for mod config
This commit is contained in:
parent
afbfeda616
commit
7091f7648d
34 changed files with 293 additions and 169 deletions
|
|
@ -5,7 +5,7 @@ plugins {
|
|||
`build-dashboard`
|
||||
}
|
||||
|
||||
group = "dev.adamko.factoriowebmap"
|
||||
group = "dev.adamko"
|
||||
version = "0.0.7"
|
||||
|
||||
tasks.wrapper {
|
||||
|
|
@ -13,13 +13,20 @@ tasks.wrapper {
|
|||
distributionType = Wrapper.DistributionType.ALL
|
||||
}
|
||||
|
||||
idea {
|
||||
module {
|
||||
isDownloadSources = true
|
||||
isDownloadJavadoc = true
|
||||
}
|
||||
val startInfra by tasks.registering {
|
||||
group = project.name
|
||||
|
||||
dependsOn(
|
||||
":modules:infra-kafka-pipe:processRun",
|
||||
":modules:infra-kafka-cluster:processRun",
|
||||
)
|
||||
}
|
||||
|
||||
//tasks.withType(HtmlDependencyReportTask::class).configureEach {
|
||||
// projects = project.allprojects
|
||||
//}
|
||||
val runKafkatorio by tasks.registering {
|
||||
group = project.name
|
||||
|
||||
dependsOn(
|
||||
":modules:infra-factorio-client:processRun",
|
||||
":modules:infra-factorio-server:processRun",
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ dependencies {
|
|||
implementation(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion"))
|
||||
implementation("org.jetbrains.kotlin:kotlin-serialization")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
|
||||
val kotlinXSerializationVersion = "1.3.1"
|
||||
implementation(enforcedPlatform("org.jetbrains.kotlinx:kotlinx-serialization-bom:$kotlinXSerializationVersion"))
|
||||
|
|
@ -35,7 +35,6 @@ tasks.withType<KotlinCompile>().configureEach {
|
|||
}
|
||||
|
||||
kotlinOptions.freeCompilerArgs += listOf(
|
||||
"-Xopt-in=kotlin.OptIn",
|
||||
"-Xopt-in=kotlin.RequiresOptIn",
|
||||
"-Xopt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-Xopt-in=kotlin.time.ExperimentalTime",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
package dev.adamko.kafkatorio
|
||||
|
||||
import org.gradle.kotlin.dsl.base
|
||||
import org.gradle.kotlin.dsl.extra
|
||||
import org.gradle.kotlin.dsl.idea
|
||||
|
||||
plugins {
|
||||
idea
|
||||
base
|
||||
|
|
@ -14,8 +10,8 @@ version = rootProject.version
|
|||
|
||||
val licenseFile: RegularFile by extra(rootProject.layout.projectDirectory.file("LICENSE"))
|
||||
|
||||
val tokens: Map<String, String> by extra(
|
||||
mapOf(
|
||||
val tokens: MutableMap<String, String> by extra(
|
||||
mutableMapOf(
|
||||
"project.version" to "$version",
|
||||
)
|
||||
)
|
||||
|
|
@ -27,6 +23,7 @@ idea {
|
|||
}
|
||||
}
|
||||
|
||||
//group = "dev.adamko.factoriowebmap"
|
||||
//version = "0.0.1"
|
||||
|
||||
tasks.withType<WriteProperties>().configureEach {
|
||||
encoding = Charsets.UTF_8.name()
|
||||
comment = " Do not edit manually. This file was created with task '$name'"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package dev.adamko.kafkatorio.infra
|
||||
|
||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||
|
||||
plugins {
|
||||
id("dev.adamko.kafkatorio.infra.process-runner")
|
||||
}
|
||||
|
||||
val dockerComposeTaskGroup : String by extra("docker-compose")
|
||||
|
||||
val composeProjectName: String by extra(rootProject.name)
|
||||
val srcDir: Directory by extra(layout.projectDirectory.dir("src"))
|
||||
|
||||
|
||||
val dockerUp by tasks.creating(Exec::class) {
|
||||
group = dockerComposeTaskGroup
|
||||
workingDir = srcDir.asFile
|
||||
commandLine = parseSpaceSeparatedArgs(""" docker-compose up -d """)
|
||||
}
|
||||
|
||||
val dockerDown by tasks.creating(Exec::class) {
|
||||
group = dockerComposeTaskGroup
|
||||
workingDir = srcDir.asFile
|
||||
commandLine = parseSpaceSeparatedArgs(""" docker-compose down """)
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks.named("processRun") { dependsOn(dockerUp, updateEnv) }
|
||||
tasks.named("processKill") { dependsOn(dockerDown) }
|
||||
}
|
||||
|
||||
val updateEnv by tasks.registering(WriteProperties::class) {
|
||||
group = dockerComposeTaskGroup
|
||||
|
||||
setOutputFile(srcDir.file(".env"))
|
||||
properties(
|
||||
"COMPOSE_PROJECT_NAME" to composeProjectName,
|
||||
)
|
||||
}
|
||||
|
||||
tasks.assemble { dependsOn(updateEnv) }
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
package dev.adamko.kafkatorio
|
||||
|
||||
import org.gradle.kotlin.dsl.extra
|
||||
import org.gradle.kotlin.dsl.registering
|
||||
package dev.adamko.kafkatorio.infra
|
||||
|
||||
plugins {
|
||||
id("dev.adamko.kafkatorio.base")
|
||||
|
|
@ -9,18 +6,17 @@ plugins {
|
|||
|
||||
val processRunnerTaskGroup: String by extra("processes")
|
||||
|
||||
val processRun by tasks.registering {
|
||||
val processRun by tasks.registering(Task::class) {
|
||||
group = processRunnerTaskGroup
|
||||
}
|
||||
|
||||
val processKill by tasks.registering {
|
||||
val processKill by tasks.registering(Task::class) {
|
||||
group = processRunnerTaskGroup
|
||||
}
|
||||
|
||||
val processRestart by tasks.registering {
|
||||
group = processRunnerTaskGroup
|
||||
|
||||
processKill.get().state
|
||||
dependsOn(processKill)
|
||||
finalizedBy(processRun)
|
||||
}
|
||||
|
|
@ -55,7 +55,6 @@ tasks.withType<KotlinCompile>().configureEach {
|
|||
}
|
||||
|
||||
kotlinOptions.freeCompilerArgs += listOf(
|
||||
"-Xopt-in=kotlin.OptIn",
|
||||
"-Xopt-in=kotlin.RequiresOptIn",
|
||||
"-Xopt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-Xopt-in=kotlin.time.ExperimentalTime",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ kotlinx-serialization = "1.3.1"
|
|||
junit = "5.8.1"
|
||||
kotest = "4.6.3"
|
||||
|
||||
## infra ##
|
||||
factorio = "1.1.48"
|
||||
|
||||
#########
|
||||
[plugins]
|
||||
|
|
|
|||
|
|
@ -10,23 +10,42 @@ import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
|||
plugins {
|
||||
idea
|
||||
id("dev.adamko.kafkatorio.lang.node")
|
||||
distribution
|
||||
}
|
||||
|
||||
val tokens: Map<String, String> by project.extra
|
||||
val licenseFile: RegularFile by project.extra
|
||||
description =
|
||||
"Sends in-game information to a server over the internet (requires Kafkatorio Kafka-Pipe)"
|
||||
|
||||
|
||||
// Factorio required format is:
|
||||
// - filename: `mod-name_version.zip`
|
||||
// - zip contains one directory, `mod-name`
|
||||
val modName: String by extra("${rootProject.name}-events")
|
||||
val distributionZipName: String by extra("${modName}_${project.version}.zip")
|
||||
|
||||
|
||||
val tokens: MutableMap<String, String> by project.extra
|
||||
tokens += mapOf(
|
||||
"mod.name" to modName,
|
||||
"mod.title" to "Kafkatorio Events",
|
||||
"mod.description" to (project.description ?: ""),
|
||||
"factorio.version" to libs.versions.factorio.get().substringBeforeLast("."),
|
||||
)
|
||||
|
||||
val licenseFile: RegularFile by project.extra
|
||||
val tsSrcDir: Directory = layout.projectDirectory.dir("src/main/typescript")
|
||||
|
||||
node {
|
||||
nodeProjectDir.set(tsSrcDir)
|
||||
}
|
||||
|
||||
val typescriptEventsSchema by configurations.registering {
|
||||
val typescriptEventsSchema: Configuration by configurations.creating {
|
||||
asConsumer()
|
||||
typescriptAttributes(objects)
|
||||
defaultDependencies {
|
||||
project.dependencies.create(projects.modules.eventsSchema)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
typescriptEventsSchema(projects.modules.eventsSchema)
|
||||
}
|
||||
|
||||
val typescriptToLua by tasks.registering(NpmTask::class) {
|
||||
|
|
@ -39,13 +58,12 @@ val typescriptToLua by tasks.registering(NpmTask::class) {
|
|||
|
||||
npmCommand.set(listOf("run", "build"))
|
||||
|
||||
inputs.dir(project.node.nodeProjectDir)
|
||||
inputs.dir(tsSrcDir)
|
||||
.skipWhenEmpty()
|
||||
.withPropertyName("sourceFiles")
|
||||
.withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
|
||||
val intermediateOutputDir = temporaryDir
|
||||
args.set(parseSpaceSeparatedArgs("-- --outDir $intermediateOutputDir"))
|
||||
args.set(parseSpaceSeparatedArgs("-- --outDir $temporaryDir"))
|
||||
val outputDir = layout.buildDirectory.dir("typescriptToLua")
|
||||
outputs.dir(outputDir)
|
||||
.withPropertyName("outputDir")
|
||||
|
|
@ -53,12 +71,13 @@ val typescriptToLua by tasks.registering(NpmTask::class) {
|
|||
ignoreExitValue.set(false)
|
||||
|
||||
doFirst("clean") {
|
||||
delete(intermediateOutputDir)
|
||||
delete(temporaryDir)
|
||||
mkdir(temporaryDir)
|
||||
}
|
||||
|
||||
doLast("syncTstlOutput") {
|
||||
sync {
|
||||
from(intermediateOutputDir)
|
||||
from(temporaryDir)
|
||||
into(outputDir)
|
||||
}
|
||||
}
|
||||
|
|
@ -66,54 +85,86 @@ val typescriptToLua by tasks.registering(NpmTask::class) {
|
|||
}
|
||||
|
||||
val fetchEventsSchema by tasks.registering(Sync::class) {
|
||||
group = project.name
|
||||
description = "Fetch the latest shared data-model"
|
||||
group = project.name
|
||||
|
||||
dependsOn(typescriptEventsSchema)
|
||||
|
||||
from(
|
||||
typescriptEventsSchema.map { c ->
|
||||
c.incoming
|
||||
typescriptEventsSchema.incoming
|
||||
.artifactView { lenient(true) }
|
||||
.artifacts
|
||||
.artifactFiles
|
||||
.filter { file -> file.exists() }
|
||||
.files
|
||||
.map { zipTree(it) }
|
||||
) {
|
||||
// drop the first directory inside the zip
|
||||
eachFile {
|
||||
relativePath = RelativePath(true, *relativePath.segments.drop(1).toTypedArray())
|
||||
}
|
||||
includeEmptyDirs = false
|
||||
}
|
||||
)
|
||||
|
||||
into(layout.projectDirectory.dir("src/main/typescript/model"))
|
||||
into(layout.projectDirectory.dir("src/main/typescript/schema"))
|
||||
}
|
||||
|
||||
val packageMod by tasks.registering(Zip::class) {
|
||||
description = "Package mod files into ZIP"
|
||||
group = project.name
|
||||
tasks.distZip {
|
||||
archiveFileName.set(distributionZipName)
|
||||
}
|
||||
|
||||
dependsOn(typescriptToLua)
|
||||
distributions {
|
||||
main {
|
||||
|
||||
inputs.properties(tokens)
|
||||
distributionBaseName.set(modName)
|
||||
|
||||
contents {
|
||||
from(layout.projectDirectory.dir("src/main/resources/mod-data")) {
|
||||
include("**/**")
|
||||
filter<ReplaceTokens>("tokens" to tokens)
|
||||
}
|
||||
dependsOn(typescriptToLua)
|
||||
from(licenseFile)
|
||||
from(typescriptToLua.map { it.outputs })
|
||||
includeEmptyDirs = false
|
||||
exclude {
|
||||
it.file.run {
|
||||
isFile && useLines { lines -> lines.all { line -> line.isBlank() } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
into(rootProject.name)
|
||||
|
||||
// Factorio required format is:
|
||||
// - filename: `mod-name_version.zip`
|
||||
// - zip contains one directory, `mod-name`
|
||||
archiveFileName.set("${rootProject.name}_${project.version}.zip")
|
||||
destinationDirectory.set(layout.buildDirectory.dir("dist"))
|
||||
|
||||
doLast {
|
||||
val outDir = destinationDirectory.asFile.get().toRelativeString(layout.projectDirectory.asFile)
|
||||
val outZip = "${archiveFileName.orNull}"
|
||||
logger.lifecycle("Packaged mod into $outDir/$outZip")
|
||||
}
|
||||
}
|
||||
|
||||
//val packageMod by tasks.registering(Zip::class) {
|
||||
// description = "Package mod files into ZIP"
|
||||
// group = project.name
|
||||
//
|
||||
// dependsOn(typescriptToLua)
|
||||
//
|
||||
// inputs.properties(tokens)
|
||||
//
|
||||
// from(layout.projectDirectory.dir("src/main/resources/mod-data")) {
|
||||
// include("**/**")
|
||||
// filter<ReplaceTokens>("tokens" to tokens)
|
||||
// }
|
||||
// from(licenseFile)
|
||||
//
|
||||
// into(rootProject.name)
|
||||
//
|
||||
// // Factorio required format is:
|
||||
// // - filename: `mod-name_version.zip`
|
||||
// // - zip contains one directory, `mod-name`
|
||||
// archiveFileName.set("${rootProject.name}_${project.version}.zip")
|
||||
// destinationDirectory.set(layout.buildDirectory.dir("dist"))
|
||||
//
|
||||
// doLast {
|
||||
// val outDir = destinationDirectory.asFile.get().toRelativeString(layout.projectDirectory.asFile)
|
||||
// val outZip = "${archiveFileName.orNull}"
|
||||
// logger.lifecycle("Packaged mod into $outDir/$outZip")
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
val downloadFactorioApiDocs by tasks.registering {
|
||||
group = project.name
|
||||
|
|
@ -148,7 +199,7 @@ val downloadFactorioApiDocs by tasks.registering {
|
|||
val factorioModProvider by configurations.registering {
|
||||
asProvider()
|
||||
factorioModAttributes(objects)
|
||||
outgoing.artifact(packageMod)
|
||||
outgoing.artifact(tasks.distZip.flatMap { it.archiveFile })
|
||||
}
|
||||
|
||||
tasks.updatePackageJson {
|
||||
|
|
@ -157,7 +208,7 @@ tasks.updatePackageJson {
|
|||
}
|
||||
|
||||
tasks.assemble { dependsOn(fetchEventsSchema, tasks.updatePackageJson) }
|
||||
tasks.build { dependsOn(packageMod) }
|
||||
//tasks.build { dependsOn(packageMod) }
|
||||
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.0.1
|
||||
Features:
|
||||
- Factorio Web Map
|
||||
- Kafkatorio
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
"name": "factorio-web-map",
|
||||
"name": "@mod.name@",
|
||||
"version": "@project.version@",
|
||||
"title": "Factorio Web Map",
|
||||
"title": "@mod.title@",
|
||||
"description": "@mod.description@",
|
||||
"author": "fredthedeadhead",
|
||||
"factorio_version": "1.1",
|
||||
"factorio_version": "@factorio.version@",
|
||||
"dependencies": []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,9 +90,13 @@ script.on_event(
|
|||
(e: OnTickEvent) => {
|
||||
if (e.tick % 60 == 0) {
|
||||
|
||||
for (const [index,] of pairs(game.surfaces)) {
|
||||
let surface = game.surfaces[index]
|
||||
surfaceEvent(e.tick, surface, mapEventIdToName.get(e.name))
|
||||
|
||||
for (const [index, _] of pairs(game.surfaces)) {
|
||||
let s = game.get_surface(index) // TODO fix / report can't iterate over surfaces
|
||||
// let surface = game.surfaces[index]
|
||||
if (s != undefined) {
|
||||
surfaceEvent(e.tick, s, mapEventIdToName.get(e.name))
|
||||
}
|
||||
// surfaceEvent(e.tick, surface, "on_tick")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "factorio-web-map-mod",
|
||||
"name": "kafkatorio-events-mod",
|
||||
"version": "0.0.7",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
},
|
||||
"devDependencies": {},
|
||||
"dependencies": {
|
||||
"lua-types": "^2.11.0",
|
||||
"@types/node": "^12.0.8",
|
||||
|
|
@ -21,10 +20,7 @@
|
|||
"//": {
|
||||
"typed-factorio": "0.10.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
},
|
||||
"optionalDependencies": {
|
||||
},
|
||||
"bundledDependencies": [
|
||||
]
|
||||
"peerDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package dev.adamko.kafkatorio.processor
|
||||
|
||||
import dev.adamko.kafkatorio.events.schema.FactorioEvent
|
||||
import dev.adamko.kafkatorio.events.schema.FactorioObjectData
|
||||
import dev.adamko.kafkatorio.events.schema.jsonMapper
|
||||
import dev.adamko.kafkatorio.processor.config.ApplicationProperties
|
||||
import java.time.Duration
|
||||
|
|
@ -25,7 +26,7 @@ fun main() {
|
|||
.mapValues { readOnlyKey, value ->
|
||||
println("Mapping $readOnlyKey:$value")
|
||||
// jsonMapper.decodeFromString<FactorioEvent<*>>(value)
|
||||
KotlinxSerialization.asA<FactorioEvent<*>>(value)
|
||||
KotlinxSerialization.asA<FactorioEvent<FactorioObjectData>>(value)
|
||||
}
|
||||
.to(TopicNameExtractor { key, value, recordContext ->
|
||||
value.data.objectName
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import dev.adamko.kafkatorio.gradle.typescriptAttributes
|
|||
plugins {
|
||||
id("dev.adamko.kafkatorio.lang.kotlin-jvm")
|
||||
kotlin("plugin.serialization")
|
||||
distribution
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
@ -18,26 +19,36 @@ dependencies {
|
|||
val generateTypescript by tasks.registering(JavaExec::class) {
|
||||
group = project.name
|
||||
|
||||
val generatedFileName = "$temporaryDir/data-model.ts"
|
||||
inputs.property("generatedFileName", generatedFileName)
|
||||
outputs.file(generatedFileName)
|
||||
val generatedFile = file("$temporaryDir/${project.name}.ts")
|
||||
|
||||
classpath(sourceSets.main.map { it.runtimeClasspath })
|
||||
mainClass.set("dev.adamko.factorioevents.model.Kt2tsKt")
|
||||
args(generatedFileName)
|
||||
mainClass.set("dev.adamko.kafkatorio.events.schema.Kt2tsKt")
|
||||
args(generatedFile)
|
||||
|
||||
val buildOutput = layout.buildDirectory.dir("generated/typescript")
|
||||
outputs.dir(buildOutput)
|
||||
|
||||
doFirst {
|
||||
delete(temporaryDir)
|
||||
mkdir(temporaryDir)
|
||||
}
|
||||
|
||||
doLast {
|
||||
sync { from(temporaryDir); into(buildOutput) }
|
||||
}
|
||||
}
|
||||
|
||||
distributions {
|
||||
main {
|
||||
distributionBaseName.set("${rootProject.name}-${project.name}")
|
||||
contents {
|
||||
from(generateTypescript.map { it.outputs.files.asFileTree })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val typescriptModelGenerated by configurations.registering {
|
||||
asProvider()
|
||||
typescriptAttributes(objects)
|
||||
outgoing.artifact(
|
||||
generateTypescript.map {
|
||||
it.outputs.files.singleFile
|
||||
}
|
||||
)
|
||||
outgoing.artifact(tasks.distZip.flatMap { it.archiveFile })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ import dev.adamko.kafkatorio.gradle.not
|
|||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||
|
||||
plugins {
|
||||
id("dev.adamko.kafkatorio.process-runner")
|
||||
id("dev.adamko.kafkatorio.infra.process-runner")
|
||||
}
|
||||
|
||||
val tokens: Map<String, String> by project.extra
|
||||
|
||||
val clientModsDirectory = file("""D:\Users\Adam\AppData\Roaming\Factorio\mods""")
|
||||
val factorioGameId = "427520"
|
||||
val steamExe = """C:\Program Files (x86)\Steam\steam.exe"""
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
import dev.adamko.kafkatorio.gradle.asConsumer
|
||||
import dev.adamko.kafkatorio.gradle.factorioModAttributes
|
||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||
|
||||
plugins {
|
||||
id("dev.adamko.kafkatorio.process-runner")
|
||||
id("dev.adamko.kafkatorio.infra.docker-compose")
|
||||
}
|
||||
|
||||
val tokens: Map<String, String> by project.extra
|
||||
|
||||
val modInfraDir: Directory = layout.projectDirectory.dir("infra")
|
||||
val factorioServerDataDir: Directory = modInfraDir.dir("factorio-server")
|
||||
val srcDir: Directory by extra
|
||||
val factorioServerDataDir: Directory = srcDir.dir("factorio-server")
|
||||
|
||||
val factorioMod: Configuration by configurations.creating {
|
||||
asConsumer()
|
||||
|
|
@ -32,46 +29,58 @@ val deployModToServer by tasks.registering(Copy::class) {
|
|||
}
|
||||
}
|
||||
|
||||
//<editor-fold desc="Factorio server lifecycle tasks">
|
||||
val factorioServerStop = tasks.register<Exec>("factorioServerStop") {
|
||||
group = project.name
|
||||
|
||||
mustRunAfter(deployModToServer)
|
||||
|
||||
workingDir(modInfraDir)
|
||||
commandLine = parseSpaceSeparatedArgs("docker-compose stop factorio-server")
|
||||
tasks.dockerUp {
|
||||
dependsOn(
|
||||
deployModToServer,
|
||||
":modules:infra-kafka-cluster:processRun",
|
||||
)
|
||||
}
|
||||
|
||||
val factorioServerUp = tasks.register<Exec>("factorioServerUp") {
|
||||
group = project.name
|
||||
|
||||
mustRunAfter(deployModToServer)
|
||||
dependsOn(factorioServerStop)
|
||||
|
||||
workingDir(modInfraDir)
|
||||
commandLine = parseSpaceSeparatedArgs("docker-compose up -d factorio-server")
|
||||
tasks.updateEnv {
|
||||
properties("FACTORIO_VERSION" to libs.versions.factorio.get())
|
||||
}
|
||||
|
||||
val factorioServerRestart: Task by tasks.creating {
|
||||
group = project.name
|
||||
|
||||
dependsOn(factorioServerStop, factorioServerUp)
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
tasks.build { dependsOn(deployModToServer) }
|
||||
|
||||
tasks.processRun {
|
||||
description = "Build the mod, upload to Server and Client, and start both"
|
||||
dependsOn(
|
||||
deployModToServer,
|
||||
factorioServerRestart,
|
||||
)
|
||||
}
|
||||
//<editor-fold desc="Factorio server lifecycle tasks">
|
||||
//val factorioServerStop = tasks.register<Exec>("factorioServerStop") {
|
||||
// group = project.name
|
||||
//
|
||||
// mustRunAfter(deployModToServer)
|
||||
//
|
||||
// workingDir(modInfraDir)
|
||||
// commandLine = parseSpaceSeparatedArgs("docker-compose stop factorio-server")
|
||||
//}
|
||||
|
||||
tasks.processKill {
|
||||
dependsOn(
|
||||
factorioServerStop,
|
||||
)
|
||||
}
|
||||
//val factorioServerUp = tasks.register<Exec>("factorioServerUp") {
|
||||
// group = project.name
|
||||
//
|
||||
// mustRunAfter(deployModToServer)
|
||||
// dependsOn(factorioServerStop)
|
||||
//
|
||||
// workingDir(modInfraDir)
|
||||
// commandLine = parseSpaceSeparatedArgs("docker-compose up -d factorio-server")
|
||||
//}
|
||||
|
||||
//val factorioServerRestart: Task by tasks.creating {
|
||||
// group = project.name
|
||||
//
|
||||
// dependsOn(factorioServerStop, factorioServerUp)
|
||||
//}
|
||||
//</editor-fold>
|
||||
|
||||
//
|
||||
//tasks.processRun {
|
||||
// description = "Build the mod, upload to Server and Client, and start both"
|
||||
// dependsOn(
|
||||
// deployModToServer,
|
||||
// factorioServerRestart,
|
||||
// )
|
||||
//}
|
||||
//
|
||||
//tasks.processKill {
|
||||
// dependsOn(
|
||||
// factorioServerStop,
|
||||
// )
|
||||
//}
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
COMPOSE_PROJECT_NAME=factorio-infra
|
||||
3
modules/infra-factorio-server/src/.env
Normal file
3
modules/infra-factorio-server/src/.env
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Do not edit manually. This file was created with task 'updateEnv'
|
||||
COMPOSE_PROJECT_NAME=kafkatorio
|
||||
FACTORIO_VERSION=1.1.48
|
||||
|
|
@ -3,13 +3,13 @@ version: "3.9"
|
|||
services:
|
||||
|
||||
factorio-server:
|
||||
image: factoriotools/factorio:1.1.48
|
||||
image: factoriotools/factorio:${FACTORIO_VERSION}
|
||||
# logging:
|
||||
# driver: "json-file"
|
||||
container_name: "factorio-server"
|
||||
restart: "unless-stopped"
|
||||
networks:
|
||||
- "factorio-events-nw"
|
||||
- "kafkatorio-nw"
|
||||
ports:
|
||||
- "34197:34197/udp" # factorio
|
||||
- "27015:27015/tcp" # rcon
|
||||
|
|
@ -32,8 +32,6 @@ services:
|
|||
# - TOKEN=FactorioToken
|
||||
|
||||
networks:
|
||||
kafka-nw:
|
||||
name: "kafka-nw"
|
||||
kafkatorio-nw:
|
||||
name: "kafkatorio-nw"
|
||||
external: true
|
||||
factorio-events-nw:
|
||||
name: "factorio-events-nw"
|
||||
|
|
@ -3,7 +3,11 @@ ARG factorioVersion=1.1.42
|
|||
|
||||
FROM factoriotools/factorio:$factorioVersion
|
||||
|
||||
|
||||
# In progress
|
||||
# The intention is to remove kafka-pipe and have a
|
||||
# pre-preared Factorio Docker container than can
|
||||
# just run, without needing an additional
|
||||
# container with kcat.
|
||||
|
||||
#RUN apk add --update \
|
||||
# curl \
|
||||
|
|
@ -19,5 +23,3 @@ RUN apt-get update && apt-get install -y \
|
|||
|
||||
WORKDIR /
|
||||
COPY kafka-pipe.sh kafka-pipe.sh
|
||||
|
||||
|
||||
5
modules/infra-kafka-cluster/build.gradle.kts
Normal file
5
modules/infra-kafka-cluster/build.gradle.kts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
plugins {
|
||||
id("dev.adamko.kafkatorio.infra.docker-compose")
|
||||
}
|
||||
|
||||
description = "Kafka cluster"
|
||||
2
modules/infra-kafka-cluster/src/.env
Normal file
2
modules/infra-kafka-cluster/src/.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Do not edit manually. This file was created with task 'updateEnv'
|
||||
COMPOSE_PROJECT_NAME=kafkatorio
|
||||
|
|
@ -13,21 +13,21 @@ services:
|
|||
KAFKA_DL_URL: "https://dlcdn.apache.org/kafka/3.0.0/kafka_2.13-3.0.0.tgz"
|
||||
networks:
|
||||
- "kafka-nw"
|
||||
- "factorio-events-nw"
|
||||
- "kafkatorio-nw"
|
||||
ports:
|
||||
- "9092:9092"
|
||||
- "9093:9093"
|
||||
|
||||
kafka-ui:
|
||||
image: provectuslabs/kafka-ui:0.2.1
|
||||
container_name: kafka-ui
|
||||
container_name: "kafka-ui"
|
||||
restart: "unless-stopped"
|
||||
networks:
|
||||
- "kafka-nw"
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
- KAFKA_CLUSTERS_0_NAME=factorio-events
|
||||
- KAFKA_CLUSTERS_0_NAME=${COMPOSE_PROJECT_NAME}
|
||||
- KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:29092
|
||||
# - KAFKA_CLUSTERS_0_ZOOKEEPER=kafka:9093
|
||||
|
||||
|
|
@ -48,6 +48,5 @@ services:
|
|||
networks:
|
||||
kafka-nw:
|
||||
name: "kafka-nw"
|
||||
factorio-events-nw:
|
||||
name: "factorio-events-nw"
|
||||
external: true
|
||||
kafkatorio-nw:
|
||||
name: "kafkatorio-nw"
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
plugins {
|
||||
id("dev.adamko.kafkatorio.process-runner")
|
||||
id("dev.adamko.kafkatorio.infra.docker-compose")
|
||||
}
|
||||
|
||||
description = "Send events from a Factorio server to a Kafka topic "
|
||||
|
||||
tasks.dockerUp {
|
||||
dependsOn(":modules:infra-kafka-cluster:dockerUp")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
COMPOSE_PROJECT_NAME=factorio-events-kafka-pipe
|
||||
# Do not edit manually. This file was created with task 'updateEnv'
|
||||
COMPOSE_PROJECT_NAME=kafkatorio
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
version: "3.9"
|
||||
|
||||
services:
|
||||
factorio-events-kafka-pipe:
|
||||
kafka-pipe:
|
||||
image: openjdk:11-jre-buster
|
||||
container_name: "factorio-events-kafka-pipe"
|
||||
container_name: "kafka-pipe"
|
||||
build:
|
||||
dockerfile: "kafka-pipe.Dockerfile"
|
||||
restart: "unless-stopped"
|
||||
privileged: true
|
||||
networks:
|
||||
- "factorio-events-nw"
|
||||
- "kafkatorio-nw"
|
||||
environment:
|
||||
FACTORIO_SERVER_CONTAINER_NAME: "factorio-server"
|
||||
KAFKA_HOST: "kafka:29092"
|
||||
|
|
@ -20,6 +20,6 @@ services:
|
|||
# - "/var/run/docker.sock:/var/run/docker.sock"
|
||||
|
||||
networks:
|
||||
factorio-events-nw:
|
||||
name: "factorio-events-nw"
|
||||
kafkatorio-nw:
|
||||
name: "kafkatorio-nw"
|
||||
external: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue