migrate docker-compose convention plugin out of buildSrc
This commit is contained in:
parent
105555bf6c
commit
f804c39a3b
32 changed files with 564 additions and 239 deletions
|
|
@ -1,18 +1,20 @@
|
||||||
|
import kafkatorio.conventions.overrideKotlinLanguageVersion
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
idea
|
id("kafkatorio.conventions.kotlin-dsl")
|
||||||
`kotlin-dsl`
|
// idea
|
||||||
kotlin("jvm") version embeddedKotlinVersion
|
// `kotlin-dsl`
|
||||||
|
// kotlin("jvm") //version "1.7.20" // embeddedKotlinVersion
|
||||||
kotlin("plugin.serialization") version embeddedKotlinVersion
|
kotlin("plugin.serialization") version embeddedKotlinVersion
|
||||||
|
// kotlin("plugin.serialization") version "1.7.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
val gradleJvmTarget = "11"
|
//val gradleJvmTarget = "11"
|
||||||
val gradleKotlinTarget = "1.6"
|
//val gradleKotlinTarget = "1.6"
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation(platform(libs.kotlin.bom))
|
implementation(platform(libs.kotlin.bom))
|
||||||
implementation("org.jetbrains.kotlin:kotlin-serialization")
|
implementation("org.jetbrains.kotlin:kotlin-serialization")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||||
|
|
@ -72,9 +74,9 @@ dependencies {
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
tasks.withType<KotlinCompile>().configureEach {
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = gradleJvmTarget
|
// jvmTarget = gradleJvmTarget
|
||||||
apiVersion = gradleKotlinTarget
|
// apiVersion = gradleKotlinTarget
|
||||||
languageVersion = gradleKotlinTarget
|
// languageVersion = gradleKotlinTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions.freeCompilerArgs += listOf(
|
kotlinOptions.freeCompilerArgs += listOf(
|
||||||
|
|
@ -88,28 +90,29 @@ tasks.withType<KotlinCompile>().configureEach {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
afterEvaluate {
|
overrideKotlinLanguageVersion("1.6")
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
//afterEvaluate {
|
||||||
kotlinOptions {
|
// tasks.withType<KotlinCompile>().configureEach {
|
||||||
apiVersion = gradleKotlinTarget
|
// kotlinOptions {
|
||||||
languageVersion = gradleKotlinTarget
|
// apiVersion = gradleKotlinTarget
|
||||||
}
|
// languageVersion = gradleKotlinTarget
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
kotlin {
|
//kotlin {
|
||||||
jvmToolchain {
|
// jvmToolchain {
|
||||||
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget))
|
// (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget))
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//kotlinDslPluginOptions {
|
||||||
|
// jvmTarget.set(gradleJvmTarget)
|
||||||
|
//}
|
||||||
|
|
||||||
kotlinDslPluginOptions {
|
//idea {
|
||||||
jvmTarget.set(gradleJvmTarget)
|
// module {
|
||||||
}
|
// isDownloadSources = true
|
||||||
|
// isDownloadJavadoc = true
|
||||||
idea {
|
// }
|
||||||
module {
|
//}
|
||||||
isDownloadSources = true
|
|
||||||
isDownloadJavadoc = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
package dev.adamko.kafkatorio.factoriomod
|
|
||||||
|
|
||||||
object FactorioMod {
|
|
||||||
|
|
||||||
const val TASK_GROUP = "factorioMod"
|
|
||||||
|
|
||||||
/** Lifecycle task for publishing the mod locally */
|
|
||||||
const val PUBLISH_MOD_LOCAL_TASK_NAME = "publishModLocal"
|
|
||||||
|
|
||||||
const val PUBLISH_MOD_TASK_NAME = "publishMod"
|
|
||||||
|
|
||||||
}
|
|
||||||
25
buildSrc/src/main/kotlin/extensions.kt
Normal file
25
buildSrc/src/main/kotlin/extensions.kt
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
import org.gradle.api.artifacts.Configuration
|
||||||
|
import org.gradle.api.attributes.Usage
|
||||||
|
import org.gradle.api.model.ObjectFactory
|
||||||
|
import org.gradle.kotlin.dsl.named
|
||||||
|
|
||||||
|
// to be moved into gradle-plugins/builder-plugins...
|
||||||
|
|
||||||
|
|
||||||
|
fun Configuration.asProvider() {
|
||||||
|
isVisible = false
|
||||||
|
isCanBeResolved = false
|
||||||
|
isCanBeConsumed = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun Configuration.asConsumer() {
|
||||||
|
isVisible = false
|
||||||
|
isCanBeResolved = true
|
||||||
|
isCanBeConsumed = false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Configuration.typescriptAttributes(objects: ObjectFactory): Configuration =
|
||||||
|
attributes {
|
||||||
|
attribute(Usage.USAGE_ATTRIBUTE, objects.named("dev.adamko.gradle.factorio.typescriptFiles"))
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
`kotlin-dsl`
|
id("kafkatorio.conventions.kotlin-dsl")
|
||||||
kotlin("jvm") version embeddedKotlinVersion
|
// `kotlin-dsl`
|
||||||
|
// kotlin("jvm") version embeddedKotlinVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
@ -34,20 +35,20 @@ dependencies {
|
||||||
implementation(libs.kotlinx.cli)
|
implementation(libs.kotlinx.cli)
|
||||||
}
|
}
|
||||||
|
|
||||||
val gradleJvmTarget = "11"
|
//val gradleJvmTarget = "11"
|
||||||
|
//
|
||||||
kotlin {
|
//kotlin {
|
||||||
jvmToolchain {
|
// jvmToolchain {
|
||||||
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget))
|
// (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget))
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
kotlinDslPluginOptions {
|
//kotlinDslPluginOptions {
|
||||||
jvmTarget.set(gradleJvmTarget)
|
// jvmTarget.set(gradleJvmTarget)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
//tasks.withType<KotlinCompile>().configureEach {
|
||||||
kotlinOptions {
|
// kotlinOptions {
|
||||||
jvmTarget = gradleJvmTarget
|
// jvmTarget = gradleJvmTarget
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
}
|
||||||
|
|
||||||
|
val gradleJvmTarget = "11"
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(platform(kotlin("bom")))
|
||||||
|
implementation(gradleApi())
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain {
|
||||||
|
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile>().configureEach {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = gradleJvmTarget
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package kafkatorio.common
|
||||||
|
|
||||||
|
import org.gradle.api.artifacts.Configuration
|
||||||
|
|
||||||
|
|
||||||
|
fun Configuration.asProvider() {
|
||||||
|
isVisible = false
|
||||||
|
isCanBeResolved = false
|
||||||
|
isCanBeConsumed = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun Configuration.asConsumer() {
|
||||||
|
isVisible = false
|
||||||
|
isCanBeResolved = true
|
||||||
|
isCanBeConsumed = false
|
||||||
|
}
|
||||||
|
|
@ -16,3 +16,16 @@ dependencyResolutionManagement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include(
|
||||||
|
":modules:common-lib",
|
||||||
|
|
||||||
|
":modules:build-conventions",
|
||||||
|
|
||||||
|
":modules:docker-compose",
|
||||||
|
":modules:factorio-mod",
|
||||||
|
":modules:typescript",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||||
|
|
|
||||||
|
|
@ -1,63 +1,63 @@
|
||||||
package kafkatorio.conventions.infra
|
package kafkatorio.conventions.infra
|
||||||
|
|
||||||
import kafkatorio.tasks.DockerEnvUpdateTask
|
//import kafkatorio.tasks.DockerEnvUpdateTask
|
||||||
import kafkatorio.extensions.DOCKER_COMPOSE_TASK_GROUP
|
//import kafkatorio.extensions.DOCKER_COMPOSE_TASK_GROUP
|
||||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
//import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||||
|
//
|
||||||
plugins {
|
//plugins {
|
||||||
base
|
// base
|
||||||
id("kafkatorio.conventions.infra.process-runner")
|
// id("kafkatorio.conventions.infra.process-runner")
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
val dockerComposeProjectName: String by extra(rootProject.name)
|
//val dockerComposeProjectName: String by extra(rootProject.name)
|
||||||
val dockerSrcDir: Directory by extra(layout.projectDirectory.dir("src"))
|
//val dockerSrcDir: Directory by extra(layout.projectDirectory.dir("src"))
|
||||||
|
//
|
||||||
|
//
|
||||||
val dockerUp by tasks.registering(Exec::class) {
|
//val dockerUp by tasks.registering(Exec::class) {
|
||||||
group = DOCKER_COMPOSE_TASK_GROUP
|
// group = DOCKER_COMPOSE_TASK_GROUP
|
||||||
|
//
|
||||||
dependsOn(tasks.assemble)
|
// dependsOn(tasks.assemble)
|
||||||
logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
// logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
||||||
|
//
|
||||||
workingDir = dockerSrcDir.asFile
|
// workingDir = dockerSrcDir.asFile
|
||||||
commandLine = parseSpaceSeparatedArgs(""" docker-compose up -d """)
|
// commandLine = parseSpaceSeparatedArgs(""" docker-compose up -d """)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
val dockerDown by tasks.registering(Exec::class) {
|
//val dockerDown by tasks.registering(Exec::class) {
|
||||||
group = DOCKER_COMPOSE_TASK_GROUP
|
// group = DOCKER_COMPOSE_TASK_GROUP
|
||||||
|
//
|
||||||
logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
// logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
||||||
|
//
|
||||||
workingDir = dockerSrcDir.asFile
|
// workingDir = dockerSrcDir.asFile
|
||||||
commandLine = parseSpaceSeparatedArgs(""" docker-compose down """)
|
// commandLine = parseSpaceSeparatedArgs(""" docker-compose down """)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
val dockerRemove by tasks.registering(Exec::class) {
|
//val dockerRemove by tasks.registering(Exec::class) {
|
||||||
group = DOCKER_COMPOSE_TASK_GROUP
|
// group = DOCKER_COMPOSE_TASK_GROUP
|
||||||
|
//
|
||||||
logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
// logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
||||||
|
//
|
||||||
workingDir = dockerSrcDir.asFile
|
// workingDir = dockerSrcDir.asFile
|
||||||
commandLine = parseSpaceSeparatedArgs(""" docker-compose rm --stop -v -f """)
|
// commandLine = parseSpaceSeparatedArgs(""" docker-compose rm --stop -v -f """)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
tasks.matching { it.name == "processRun" }.configureEach { dependsOn(dockerUp, dockerEnvUpdate) }
|
//tasks.matching { it.name == "processRun" }.configureEach { dependsOn(dockerUp, dockerEnvUpdate) }
|
||||||
tasks.matching { it.name == "processKill" }.configureEach { dependsOn(dockerDown) }
|
//tasks.matching { it.name == "processKill" }.configureEach { dependsOn(dockerDown) }
|
||||||
|
//
|
||||||
|
//
|
||||||
val dockerEnvUpdate by tasks.registering(DockerEnvUpdateTask::class) {
|
//val dockerEnvUpdate by tasks.registering(DockerEnvUpdateTask::class) {
|
||||||
dotEnvFile.set(dockerSrcDir.file(".env"))
|
// dotEnvFile.set(dockerSrcDir.file(".env"))
|
||||||
|
//
|
||||||
properties(
|
// properties(
|
||||||
"COMPOSE_PROJECT_NAME" to dockerComposeProjectName,
|
// "COMPOSE_PROJECT_NAME" to dockerComposeProjectName,
|
||||||
"KAFKATORIO_VERSION" to project.version,
|
// "KAFKATORIO_VERSION" to project.version,
|
||||||
"REGISTRY_HOST" to providers.gradleProperty("dockerContainerRegistryHost"),
|
// "REGISTRY_HOST" to providers.gradleProperty("dockerContainerRegistryHost"),
|
||||||
)
|
// )
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
tasks.assemble { dependsOn(dockerEnvUpdate) }
|
//tasks.assemble { dependsOn(dockerEnvUpdate) }
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version embeddedKotlinVersion
|
id("kafkatorio.conventions.kotlin-dsl")
|
||||||
`kotlin-dsl`
|
// kotlin("jvm") version embeddedKotlinVersion
|
||||||
|
// `kotlin-dsl`
|
||||||
`java-gradle-plugin`
|
`java-gradle-plugin`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -13,17 +14,17 @@ dependencies {
|
||||||
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable")
|
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
//kotlin {
|
||||||
jvmToolchain {
|
// jvmToolchain {
|
||||||
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget))
|
// (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget))
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
//tasks.withType<KotlinCompile>().configureEach {
|
||||||
kotlinOptions {
|
// kotlinOptions {
|
||||||
jvmTarget = gradleJvmTarget
|
// jvmTarget = gradleJvmTarget
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
gradlePlugin {
|
gradlePlugin {
|
||||||
plugins {
|
plugins {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package kafkatorio.tasks
|
package dev.adamko.geedeecee
|
||||||
|
|
||||||
import kafkatorio.extensions.filesChecksum
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.Directory
|
||||||
import org.gradle.api.file.DirectoryProperty
|
import org.gradle.api.file.DirectoryProperty
|
||||||
import org.gradle.api.file.RegularFileProperty
|
import org.gradle.api.file.RegularFileProperty
|
||||||
import org.gradle.api.logging.LogLevel
|
import org.gradle.api.logging.LogLevel
|
||||||
|
|
@ -20,8 +20,16 @@ import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.kotlin.dsl.property
|
import org.gradle.kotlin.dsl.property
|
||||||
import org.gradle.process.ExecOperations
|
import org.gradle.process.ExecOperations
|
||||||
import org.gradle.work.NormalizeLineEndings
|
import org.gradle.work.NormalizeLineEndings
|
||||||
|
import org.jetbrains.kotlin.incremental.md5
|
||||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||||
|
|
||||||
|
|
||||||
|
// look into using 'build context' for up-to-date check
|
||||||
|
// https://stackoverflow.com/questions/38946683/how-to-test-dockerignore-file
|
||||||
|
// https://github.com/pwaller/docker-show-context
|
||||||
|
// https://snippets.khromov.se/see-which-files-are-included-in-your-docker-build-context/
|
||||||
|
|
||||||
|
|
||||||
@CacheableTask
|
@CacheableTask
|
||||||
@Suppress("UnstableApiUsage")
|
@Suppress("UnstableApiUsage")
|
||||||
abstract class DockerComposeExec @Inject constructor(
|
abstract class DockerComposeExec @Inject constructor(
|
||||||
|
|
@ -77,5 +85,12 @@ abstract class DockerComposeExec @Inject constructor(
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val DOCKER_COMPOSE_GROUP: String = "docker-compose"
|
const val DOCKER_COMPOSE_GROUP: String = "docker-compose"
|
||||||
|
|
||||||
|
|
||||||
|
private fun Directory.filesChecksum(): Long = asFileTree
|
||||||
|
.files
|
||||||
|
.map { it.readBytes() + it.absolutePath.toByteArray() }
|
||||||
|
.fold(byteArrayOf()) { acc, bytes -> acc + bytes }
|
||||||
|
.md5()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package kafkatorio.tasks
|
package dev.adamko.geedeecee
|
||||||
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kafkatorio.extensions.DOCKER_COMPOSE_TASK_GROUP
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
import org.gradle.api.file.RegularFileProperty
|
||||||
import org.gradle.api.logging.LogLevel
|
import org.gradle.api.logging.LogLevel
|
||||||
import org.gradle.api.model.ObjectFactory
|
import org.gradle.api.model.ObjectFactory
|
||||||
|
|
@ -12,14 +11,15 @@ import org.gradle.api.tasks.WriteProperties
|
||||||
|
|
||||||
@CacheableTask
|
@CacheableTask
|
||||||
open class DockerEnvUpdateTask @Inject constructor(
|
open class DockerEnvUpdateTask @Inject constructor(
|
||||||
private val objects: ObjectFactory
|
objects: ObjectFactory
|
||||||
) : WriteProperties() {
|
) : WriteProperties() {
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
|
// internal and not abstract so that it can delegate to `super.outputFile` in `init {}`
|
||||||
val dotEnvFile: RegularFileProperty = objects.fileProperty()
|
val dotEnvFile: RegularFileProperty = objects.fileProperty()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
group = DOCKER_COMPOSE_TASK_GROUP
|
group = GDCPlugin.GCD_TASK_GROUP
|
||||||
super.setOutputFile(dotEnvFile)
|
super.setOutputFile(dotEnvFile)
|
||||||
super.getLogging().captureStandardOutput(LogLevel.LIFECYCLE)
|
super.getLogging().captureStandardOutput(LogLevel.LIFECYCLE)
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package dev.adamko.geedeecee
|
||||||
|
|
||||||
|
import javax.inject.Inject
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.DirectoryProperty
|
||||||
|
import org.gradle.api.logging.LogLevel
|
||||||
|
import org.gradle.api.provider.ListProperty
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.InputDirectory
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import org.gradle.process.ExecOperations
|
||||||
|
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||||
|
|
||||||
|
abstract class GDCCommandTask @Inject constructor(
|
||||||
|
private val executor: ExecOperations
|
||||||
|
) : DefaultTask() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
super.setGroup(GDCPlugin.GCD_TASK_GROUP)
|
||||||
|
description = "Run a docker-compose command."
|
||||||
|
|
||||||
|
logging.captureStandardOutput(LogLevel.LIFECYCLE)
|
||||||
|
}
|
||||||
|
|
||||||
|
@get:InputDirectory
|
||||||
|
abstract val workingDir: DirectoryProperty
|
||||||
|
|
||||||
|
@get:Input
|
||||||
|
abstract val separatedArgs: ListProperty<String>
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
fun dockerCompose() {
|
||||||
|
val separatedArgs: List<String> = separatedArgs.get()
|
||||||
|
|
||||||
|
executor.exec {
|
||||||
|
workingDir(this@GDCCommandTask.workingDir)
|
||||||
|
commandLine(separatedArgs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("FunctionName")
|
||||||
|
fun `docker-compose`(args: String) {
|
||||||
|
separatedArgs.addAll(
|
||||||
|
parseSpaceSeparatedArgs("docker-compose $args")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
package dev.adamko.geedeecee
|
package dev.adamko.geedeecee
|
||||||
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.*
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.file.ProjectLayout
|
import org.gradle.api.file.ProjectLayout
|
||||||
import org.gradle.api.provider.ProviderFactory
|
import org.gradle.api.logging.*
|
||||||
import org.gradle.kotlin.dsl.create
|
import org.gradle.api.provider.*
|
||||||
|
import org.gradle.api.tasks.*
|
||||||
|
import org.gradle.kotlin.dsl.*
|
||||||
|
import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||||
|
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
abstract class GDCPlugin @Inject constructor(
|
abstract class GDCPlugin @Inject constructor(
|
||||||
private val providers: ProviderFactory,
|
private val providers: ProviderFactory,
|
||||||
private val layout: ProjectLayout,
|
private val layout: ProjectLayout,
|
||||||
|
|
@ -16,28 +19,79 @@ abstract class GDCPlugin @Inject constructor(
|
||||||
|
|
||||||
|
|
||||||
override fun apply(target: Project) {
|
override fun apply(target: Project) {
|
||||||
target.createSettings()
|
target.plugins.apply(LifecycleBasePlugin::class)
|
||||||
|
|
||||||
|
val gdcSettings = target.createSettings()
|
||||||
|
|
||||||
|
val dockerComposeEnvUpdate by target.tasks.registering(DockerEnvUpdateTask::class) {
|
||||||
|
dotEnvFile.set(gdcSettings.srcDir.file(".env"))
|
||||||
|
|
||||||
|
// properties(
|
||||||
|
// "COMPOSE_PROJECT_NAME" to gdcSettings.composeProjectName,
|
||||||
|
// "KAFKATORIO_VERSION" to gdcSettings.composeProjectVersion,
|
||||||
|
// "REGISTRY_HOST" to providers.gradleProperty("dockerContainerRegistryHost"),
|
||||||
|
// )
|
||||||
|
}
|
||||||
|
|
||||||
|
val dockerComposeUp by target.tasks.registering(GDCCommandTask::class) {
|
||||||
|
`docker-compose`("up -d")
|
||||||
|
}
|
||||||
|
val dockerComposeDown by target.tasks.registering(GDCCommandTask::class) {
|
||||||
|
`docker-compose`("down")
|
||||||
|
}
|
||||||
|
val dockerComposeStop by target.tasks.registering(GDCCommandTask::class) {
|
||||||
|
`docker-compose`("stop")
|
||||||
|
}
|
||||||
|
val dockerComposeBuild by target.tasks.registering(GDCCommandTask::class) {
|
||||||
|
`docker-compose`("build")
|
||||||
|
}
|
||||||
|
val dockerComposeRemove by target.tasks.registering(GDCCommandTask::class) {
|
||||||
|
`docker-compose`("rm --stop -v -f")
|
||||||
|
}
|
||||||
|
|
||||||
|
dockerComposeUp.configure { dependsOn(dockerComposeBuild) }
|
||||||
|
dockerComposeRemove.configure { dependsOn(dockerComposeDown) }
|
||||||
|
|
||||||
|
target.tasks.withType<GDCCommandTask>().configureEach {
|
||||||
|
workingDir.convention(gdcSettings.srcDir)
|
||||||
|
dependsOn(dockerComposeEnvUpdate)
|
||||||
|
}
|
||||||
|
|
||||||
|
val assembleTasks = target.tasks.matching { LifecycleBasePlugin.ASSEMBLE_TASK_NAME == it.name }
|
||||||
|
|
||||||
|
assembleTasks.configureEach {
|
||||||
|
dependsOn(dockerComposeEnvUpdate)
|
||||||
|
}
|
||||||
|
|
||||||
|
dockerComposeUp.configure {
|
||||||
|
dependsOn(assembleTasks)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun Project.createSettings(): GDCSettings =
|
private fun Project.createSettings(): GDCSettings =
|
||||||
extensions.create<GDCSettings>(GDC_EXTENSION_NAME).apply {
|
extensions.create<GDCSettings>(GDC_EXTENSION_NAME).apply {
|
||||||
composeProjectName.convention(providers.provider { project.name })
|
composeProjectName.convention(providers.provider { project.name })
|
||||||
|
composeProjectVersion.convention(providers.provider { project.name })
|
||||||
|
containerRegistryHost.convention(providers.gradleProperty("dockerContainerRegistryHost"))
|
||||||
srcDir.convention(layout.projectDirectory.dir("docker"))
|
srcDir.convention(layout.projectDirectory.dir("docker"))
|
||||||
|
|
||||||
dotEnv.put("COMPOSE_PROJECT_NAME", composeProjectName)
|
dotEnv.put("COMPOSE_PROJECT_NAME", composeProjectName)
|
||||||
dotEnv.put("PROJECT_VERSION", providers.provider { project.version.toString() })
|
dotEnv.put("PROJECT_VERSION", composeProjectVersion)
|
||||||
dotEnv.put("REGISTRY_HOST", providers.gradleProperty("dockerContainerRegistryHost"))
|
dotEnv.put("REGISTRY_HOST", containerRegistryHost)
|
||||||
|
|
||||||
enabled.convention(
|
enabled.convention(isDockerActive())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun isDockerActive(): Provider<Boolean> =
|
||||||
providers.exec {
|
providers.exec {
|
||||||
commandLine = parseSpaceSeparatedArgs("docker info")
|
commandLine = parseSpaceSeparatedArgs("docker info")
|
||||||
isIgnoreExitValue = true
|
isIgnoreExitValue = true
|
||||||
}.result.map {
|
}.result.map {
|
||||||
it.exitValue == 0
|
it.exitValue == 0
|
||||||
}
|
}
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,12 @@ interface GDCSettings {
|
||||||
@get:Input
|
@get:Input
|
||||||
val composeProjectName: Property<String>
|
val composeProjectName: Property<String>
|
||||||
|
|
||||||
|
@get:Input
|
||||||
|
val composeProjectVersion: Property<String>
|
||||||
|
|
||||||
|
@get:Input
|
||||||
|
val containerRegistryHost: Property<String>
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
val srcDir: DirectoryProperty
|
val srcDir: DirectoryProperty
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
|
import kafkatorio.conventions.overrideKotlinLanguageVersion
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
`kotlin-dsl`
|
id("kafkatorio.conventions.kotlin-dsl")
|
||||||
kotlin("jvm") version embeddedKotlinVersion
|
kotlin("plugin.serialization") version embeddedKotlinVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(platform(libs.kotlin.bom))
|
implementation(platform(libs.kotlin.bom))
|
||||||
|
|
||||||
|
|
@ -32,20 +34,42 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val gradleJvmTarget = "11"
|
//val gradleJvmTarget = 11
|
||||||
|
//
|
||||||
|
//kotlin {
|
||||||
|
// jvmToolchain(gradleJvmTarget)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//kotlinDslPluginOptions {
|
||||||
|
// jvmTarget.set("$gradleJvmTarget")
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//tasks.withType<KotlinCompile>().configureEach {
|
||||||
|
// kotlinOptions {
|
||||||
|
// jvmTarget = "$gradleJvmTarget"
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
kotlin {
|
gradlePlugin {
|
||||||
jvmToolchain {
|
plugins {
|
||||||
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget))
|
create("factorioMod") {
|
||||||
|
displayName = "Factorio Mod"
|
||||||
|
id = "dev.adamko.factorio-mod"
|
||||||
|
implementationClass = "dev.adamko.gradle.factorio.FactorioModPlugin"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinDslPluginOptions {
|
|
||||||
jvmTarget.set(gradleJvmTarget)
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
overrideKotlinLanguageVersion("1.6")
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = gradleJvmTarget
|
//val gradleKotlinTarget = "1.7"
|
||||||
}
|
//
|
||||||
}
|
//afterEvaluate {
|
||||||
|
// tasks.withType<KotlinCompile>().configureEach {
|
||||||
|
// kotlinOptions {
|
||||||
|
// apiVersion = gradleKotlinTarget
|
||||||
|
// languageVersion = gradleKotlinTarget
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package dev.adamko.gradle.factorio
|
||||||
|
|
||||||
|
import javax.inject.Inject
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection
|
||||||
|
import org.gradle.api.file.DirectoryProperty
|
||||||
|
import org.gradle.api.file.FileSystemOperations
|
||||||
|
import org.gradle.api.internal.file.FileOperations
|
||||||
|
import org.gradle.api.tasks.InputFiles
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
|
abstract class FactorioModInstallTask @Inject constructor(
|
||||||
|
private val files: FileSystemOperations,
|
||||||
|
) : DefaultTask() {
|
||||||
|
|
||||||
|
@get:Internal
|
||||||
|
abstract val clientModDirectory: DirectoryProperty
|
||||||
|
|
||||||
|
@get:InputFiles
|
||||||
|
abstract val modFiles: ConfigurableFileCollection
|
||||||
|
|
||||||
|
init {
|
||||||
|
description = "Copy the mod to the Factorio client"
|
||||||
|
group = FactorioModPlugin.TASK_GROUP
|
||||||
|
|
||||||
|
super.onlyIf {
|
||||||
|
require(it is FactorioModInstallTask)
|
||||||
|
it.clientModDirectory.asFile.get().exists()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
fun install() {
|
||||||
|
logger.lifecycle("Copying mod from $modFiles to $clientModDirectory")
|
||||||
|
|
||||||
|
files.copy {
|
||||||
|
from(modFiles)
|
||||||
|
into(clientModDirectory)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.adamko.factorio_gradle
|
package dev.adamko.gradle.factorio
|
||||||
|
|
||||||
import org.gradle.api.file.DirectoryProperty
|
import org.gradle.api.file.DirectoryProperty
|
||||||
import org.gradle.api.file.RegularFileProperty
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.adamko.kafkatorio.factoriomod.portal
|
package dev.adamko.gradle.factorio.mod_portal
|
||||||
|
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.engine.cio.CIO
|
import io.ktor.client.engine.cio.CIO
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package dev.adamko.kafkatorio.factoriomod.portal
|
package dev.adamko.gradle.factorio.mod_portal
|
||||||
|
|
||||||
import dev.adamko.kafkatorio.factoriomod.FactorioMod
|
import dev.adamko.gradle.factorio.FactorioModPlugin
|
||||||
import io.ktor.http.URLBuilder
|
import io.ktor.http.URLBuilder
|
||||||
import io.ktor.http.takeFrom
|
import io.ktor.http.takeFrom
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
@ -60,7 +60,7 @@ abstract class FactorioModPublishTask @Inject constructor(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
group = FactorioMod.TASK_GROUP
|
group = FactorioModPlugin.TASK_GROUP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.adamko.kafkatorio.factoriomod.portal
|
package dev.adamko.gradle.factorio.mod_portal
|
||||||
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
|
@ -11,6 +12,10 @@ dependencies {
|
||||||
// This project should only be providing simple plugins for configuring Gradle without
|
// This project should only be providing simple plugins for configuring Gradle without
|
||||||
// dependencies. Try to avoid setting dependencies here, else the Gradle script classpath might
|
// dependencies. Try to avoid setting dependencies here, else the Gradle script classpath might
|
||||||
// get polluted and messy.
|
// get polluted and messy.
|
||||||
|
|
||||||
|
implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:$expectedKotlinDslPluginsVersion")
|
||||||
|
// implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${embeddedKotlinVersion}")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.get()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package kafkatorio.conventions
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("org.gradle.kotlin.kotlin-dsl")
|
||||||
|
kotlin("jvm")
|
||||||
|
}
|
||||||
|
|
||||||
|
val gradleJvmTarget = 11
|
||||||
|
|
||||||
|
//kotlin {
|
||||||
|
// jvmToolchain(gradleJvmTarget)
|
||||||
|
//}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain {
|
||||||
|
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinDslPluginOptions {
|
||||||
|
jvmTarget.set("$gradleJvmTarget")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile>().configureEach {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "$gradleJvmTarget"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package kafkatorio.conventions
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||||
|
import org.gradle.jvm.toolchain.JavaToolchainSpec
|
||||||
|
import org.gradle.kotlin.dsl.plugins.dsl.*
|
||||||
|
import org.gradle.kotlin.dsl.withType
|
||||||
|
|
||||||
|
fun Project.overrideKotlinLanguageVersion(
|
||||||
|
gradleKotlinTarget: String = "1.6"
|
||||||
|
) {
|
||||||
|
afterEvaluate {
|
||||||
|
tasks.withType<KotlinCompile>().configureEach {
|
||||||
|
kotlinOptions {
|
||||||
|
apiVersion = gradleKotlinTarget
|
||||||
|
languageVersion = gradleKotlinTarget
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import kafkatorio.distributions.asProvider
|
|
||||||
import kafkatorio.distributions.typescriptAttributes
|
|
||||||
import kafkatorio.tasks.GenerateTypeScriptTask
|
import kafkatorio.tasks.GenerateTypeScriptTask
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmCompilation
|
||||||
|
|
@ -8,6 +6,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("kafkatorio.conventions.lang.kotlin-multiplatform")
|
id("kafkatorio.conventions.lang.kotlin-multiplatform")
|
||||||
|
id("dev.adamko.factorio-mod") // only needed for 'attributes' - need to split up the mod?
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
distribution
|
distribution
|
||||||
}
|
}
|
||||||
|
|
@ -28,10 +27,12 @@ kotlin {
|
||||||
jvmTarget = "11"
|
jvmTarget = "11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
testRuns["test"].executionTask.configure {
|
testRuns.configureEach {
|
||||||
|
executionTask.configure {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import dev.adamko.kafkatorio.factoriomod.portal.FactorioModPublishTask
|
import dev.adamko.gradle.factorio.mod_portal.FactorioModPublishTask
|
||||||
import kafkatorio.distributions.asConsumer
|
import dev.adamko.gradle.factorio.typescriptAttributes
|
||||||
import kafkatorio.distributions.asProvider
|
import dev.adamko.gradle.factorio.factorioModAttributes
|
||||||
import kafkatorio.distributions.factorioModAttributes
|
|
||||||
import kafkatorio.distributions.typescriptAttributes
|
|
||||||
import kafkatorio.tasks.TypescriptToLuaTask
|
import kafkatorio.tasks.TypescriptToLuaTask
|
||||||
import kotlinx.serialization.json.put
|
import kotlinx.serialization.json.put
|
||||||
import kotlinx.serialization.json.putJsonObject
|
import kotlinx.serialization.json.putJsonObject
|
||||||
|
|
@ -13,6 +11,7 @@ import org.gradle.plugins.ide.idea.model.Path as IdeaImlPath
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("kafkatorio.conventions.lang.node")
|
id("kafkatorio.conventions.lang.node")
|
||||||
|
id("dev.adamko.factorio-mod")
|
||||||
distribution
|
distribution
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("kafkatorio.conventions.lang.kotlin-jvm")
|
id("kafkatorio.conventions.lang.kotlin-jvm")
|
||||||
|
id("dev.adamko.geedeecee")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
application
|
application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
description = "Consumes Syslog Kafkatorio packets and sends them to Kafka"
|
description = "Provides a Syslog server that receives Kafkatorio packets and forwards them to Kafka"
|
||||||
|
|
||||||
val projectId: String by project.extra
|
val projectId: String by project.extra
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("kafkatorio.conventions.lang.kotlin-jvm")
|
id("kafkatorio.conventions.lang.kotlin-jvm")
|
||||||
|
id("dev.adamko.geedeecee")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
application
|
application
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import dev.adamko.kafkatorio.factoriomod.FactorioMod
|
import dev.adamko.gradle.factorio.FactorioModPlugin
|
||||||
import kafkatorio.distributions.asConsumer
|
import dev.adamko.gradle.factorio.factorioModAttributes
|
||||||
import kafkatorio.distributions.factorioModAttributes
|
|
||||||
import kafkatorio.extensions.not
|
import kafkatorio.extensions.not
|
||||||
import kafkatorio.tasks.ProcessRunningSpec
|
import kafkatorio.tasks.ProcessRunningSpec
|
||||||
import org.gradle.kotlin.dsl.support.serviceOf
|
import org.gradle.kotlin.dsl.support.serviceOf
|
||||||
|
|
@ -8,6 +7,7 @@ import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("kafkatorio.conventions.infra.process-runner")
|
id("kafkatorio.conventions.infra.process-runner")
|
||||||
|
id("dev.adamko.factorio-mod")
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "Start the Factorio game client"
|
description = "Start the Factorio game client"
|
||||||
|
|
@ -26,10 +26,10 @@ val steamExe: RegularFileProperty = objects.fileProperty().apply {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val factorioMod: Configuration by configurations.creating {
|
//val factorioMod: Configuration by configurations.creating {
|
||||||
asConsumer()
|
// asConsumer()
|
||||||
factorioModAttributes(objects)
|
// factorioModAttributes(objects)
|
||||||
}
|
//}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
factorioMod(projects.modules.eventsMod)
|
factorioMod(projects.modules.eventsMod)
|
||||||
|
|
@ -39,7 +39,7 @@ dependencies {
|
||||||
//<editor-fold desc="Mod deployment tasks">
|
//<editor-fold desc="Mod deployment tasks">
|
||||||
val deployModToLocalClient by tasks.registering(Copy::class) {
|
val deployModToLocalClient by tasks.registering(Copy::class) {
|
||||||
description = "Copy the mod to the Factorio client"
|
description = "Copy the mod to the Factorio client"
|
||||||
group = FactorioMod.TASK_GROUP
|
group = FactorioModPlugin.TASK_GROUP
|
||||||
|
|
||||||
val clientModsDirectory123 = clientModsDirectory
|
val clientModsDirectory123 = clientModsDirectory
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ fun ExecOperations.isFactorioRunning(): Spec<Task> = ProcessRunningSpec(this, "f
|
||||||
|
|
||||||
val clientLaunch by tasks.registering(Exec::class) {
|
val clientLaunch by tasks.registering(Exec::class) {
|
||||||
description = "Run local Factorio Steam game client"
|
description = "Run local Factorio Steam game client"
|
||||||
group = FactorioMod.TASK_GROUP
|
group = FactorioModPlugin.TASK_GROUP
|
||||||
|
|
||||||
val steamExe123 = steamExe
|
val steamExe123 = steamExe
|
||||||
val clientModsDirectory444 = clientModsDirectory
|
val clientModsDirectory444 = clientModsDirectory
|
||||||
|
|
@ -83,7 +83,7 @@ val clientLaunch by tasks.registering(Exec::class) {
|
||||||
|
|
||||||
val clientKill by tasks.registering(Exec::class) {
|
val clientKill by tasks.registering(Exec::class) {
|
||||||
description = "Stop the local Factorio Steam game client"
|
description = "Stop the local Factorio Steam game client"
|
||||||
group = FactorioMod.TASK_GROUP
|
group = FactorioModPlugin.TASK_GROUP
|
||||||
|
|
||||||
onlyIf(serviceOf<ExecOperations>().isFactorioRunning())
|
onlyIf(serviceOf<ExecOperations>().isFactorioRunning())
|
||||||
|
|
||||||
|
|
@ -93,8 +93,8 @@ val clientKill by tasks.registering(Exec::class) {
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
|
|
||||||
tasks.register(FactorioMod.PUBLISH_MOD_LOCAL_TASK_NAME) {
|
tasks.register(FactorioModPlugin.PUBLISH_MOD_LOCAL_TASK_NAME) {
|
||||||
group = FactorioMod.TASK_GROUP
|
group = FactorioModPlugin.TASK_GROUP
|
||||||
dependsOn(deployModToLocalClient)
|
dependsOn(deployModToLocalClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,22 @@
|
||||||
import dev.adamko.kafkatorio.factoriomod.FactorioMod
|
import dev.adamko.gradle.factorio.FactorioModPlugin
|
||||||
import kafkatorio.distributions.asConsumer
|
|
||||||
import kafkatorio.distributions.factorioModAttributes
|
|
||||||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("kafkatorio.conventions.infra.docker-compose")
|
id("dev.adamko.geedeecee")
|
||||||
|
id("dev.adamko.factorio-mod")
|
||||||
|
idea
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val dockerSrcDir: Directory by extra
|
//val dockerSrcDir: Directory by extra
|
||||||
val factorioServerDataDir: Directory = dockerSrcDir.dir("factorio-server")
|
//val factorioServerDataDir: Directory = dockerSrcDir.dir("factorio-server")
|
||||||
|
val factorioServerDataDir: DirectoryProperty = objects.directoryProperty()
|
||||||
|
.convention(geedeecee.srcDir.dir("factorio-server"))
|
||||||
|
|
||||||
|
|
||||||
val factorioMod: Configuration by configurations.creating {
|
//val factorioMod: Configuration by configurations.creating {
|
||||||
asConsumer()
|
// asConsumer()
|
||||||
factorioModAttributes(objects)
|
// factorioModAttributes(objects)
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
@ -25,13 +26,14 @@ dependencies {
|
||||||
|
|
||||||
val deployModToLocalServer by tasks.registering(Copy::class) {
|
val deployModToLocalServer by tasks.registering(Copy::class) {
|
||||||
description = "Copy the mod to the Factorio Docker server"
|
description = "Copy the mod to the Factorio Docker server"
|
||||||
group = FactorioMod.TASK_GROUP
|
group = FactorioModPlugin.TASK_GROUP
|
||||||
|
|
||||||
dependsOn(factorioMod)
|
dependsOn(factorioMod)
|
||||||
|
|
||||||
from(
|
// from(
|
||||||
provider { factorioMod.incoming.artifacts.artifactFiles.files }
|
// provider { factorioMod.incoming.artifacts.artifactFiles.files }
|
||||||
)
|
// )
|
||||||
|
from(configurations.factorioMod.map { it.incoming.artifacts.artifactFiles.files })
|
||||||
into(factorioServerDataDir.dir("mods"))
|
into(factorioServerDataDir.dir("mods"))
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
|
|
@ -40,12 +42,12 @@ val deployModToLocalServer by tasks.registering(Copy::class) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tasks.dockerDown {
|
//tasks.dockerComposeDown {
|
||||||
commandLine = parseSpaceSeparatedArgs(""" docker-compose stop """)
|
// commandLine = parseSpaceSeparatedArgs(""" docker-compose stop """)
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
tasks.dockerUp {
|
tasks.dockerComposeUp {
|
||||||
dependsOn(
|
dependsOn(
|
||||||
deployModToLocalServer,
|
deployModToLocalServer,
|
||||||
":modules:infra-kafka-cluster:processRun",
|
":modules:infra-kafka-cluster:processRun",
|
||||||
|
|
@ -56,7 +58,7 @@ tasks.dockerUp {
|
||||||
val kafkatorioServerToken: String by project
|
val kafkatorioServerToken: String by project
|
||||||
|
|
||||||
|
|
||||||
tasks.dockerEnvUpdate {
|
tasks.dockerComposeEnvUpdate {
|
||||||
properties(
|
properties(
|
||||||
"FACTORIO_VERSION" to libs.versions.factorio.get(),
|
"FACTORIO_VERSION" to libs.versions.factorio.get(),
|
||||||
"KAFKATORIO_TOKEN" to kafkatorioServerToken,
|
"KAFKATORIO_TOKEN" to kafkatorioServerToken,
|
||||||
|
|
@ -64,8 +66,8 @@ tasks.dockerEnvUpdate {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tasks.register(FactorioMod.PUBLISH_MOD_LOCAL_TASK_NAME) {
|
tasks.register(FactorioModPlugin.PUBLISH_MOD_LOCAL_TASK_NAME) {
|
||||||
group = FactorioMod.TASK_GROUP
|
group = FactorioModPlugin.TASK_GROUP
|
||||||
dependsOn(deployModToLocalServer)
|
dependsOn(deployModToLocalServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,5 +81,5 @@ idea {
|
||||||
val runFactorioServer by tasks.registering {
|
val runFactorioServer by tasks.registering {
|
||||||
group = rootProject.name
|
group = rootProject.name
|
||||||
|
|
||||||
dependsOn(tasks.processRun)
|
dependsOn(tasks.dockerComposeUp)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("kafkatorio.conventions.infra.docker-compose")
|
id("dev.adamko.geedeecee")
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "Kafka cluster"
|
description = "Kafka cluster"
|
||||||
|
|
||||||
tasks.dockerEnvUpdate {
|
geedeecee {
|
||||||
|
srcDir.set(layout.projectDirectory.dir("src"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.dockerComposeEnvUpdate {
|
||||||
properties(
|
properties(
|
||||||
"GRAFANA_VERSION" to libs.versions.grafana,
|
"GRAFANA_VERSION" to libs.versions.grafana,
|
||||||
"PROMETHEUS_VERSION" to libs.versions.prometheus,
|
"PROMETHEUS_VERSION" to libs.versions.prometheus,
|
||||||
|
|
@ -31,5 +35,5 @@ tasks.dockerEnvUpdate {
|
||||||
val runKafkaCluster by tasks.registering {
|
val runKafkaCluster by tasks.registering {
|
||||||
group = rootProject.name
|
group = rootProject.name
|
||||||
|
|
||||||
dependsOn(tasks.processRun)
|
dependsOn(tasks.dockerComposeUp)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,22 @@
|
||||||
import kafkatorio.tasks.DockerComposeExec
|
import dev.adamko.geedeecee.DockerComposeExec
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("kafkatorio.conventions.infra.docker-compose")
|
id("dev.adamko.geedeecee")
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "Send events from a Factorio server to a Kafka topic "
|
description = "Send events from a Factorio server to a Kafka topic "
|
||||||
|
|
||||||
|
|
||||||
val dockerSrcDir: Directory by extra
|
//val dockerSrcDir: Directory by extra
|
||||||
|
|
||||||
tasks.dockerUp {
|
tasks.dockerComposeUp {
|
||||||
dependsOn(":modules:infra-kafka-cluster:dockerUp")
|
dependsOn(":modules:infra-kafka-cluster:dockerUp")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val dockerBuildKafkaPipe by tasks.registering(DockerComposeExec::class) {
|
val dockerBuildKafkaPipe by tasks.registering(DockerComposeExec::class) {
|
||||||
dependsOn(tasks.dockerEnvUpdate)
|
|
||||||
|
|
||||||
dockerComposeDir.set(dockerSrcDir)
|
dockerComposeDir.set(geedeecee.srcDir)
|
||||||
command.set("docker-compose build kafka-pipe")
|
command.set("docker-compose build kafka-pipe")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import kafkatorio.tasks.DockerEnvUpdateTask
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
|
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
|
||||||
|
|
||||||
|
|
@ -7,6 +6,7 @@ plugins {
|
||||||
id("kafkatorio.conventions.lang.kotlin-js")
|
id("kafkatorio.conventions.lang.kotlin-js")
|
||||||
id("io.kvision")
|
id("io.kvision")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
|
id("dev.adamko.geedeecee")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -115,17 +115,18 @@ fun KotlinDependencyHandler.kvision(
|
||||||
implementation("io.kvision:$module:${version.get()}", configure)
|
implementation("io.kvision:$module:${version.get()}", configure)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
geedeecee {
|
||||||
|
srcDir.set(layout.projectDirectory.dir("docker"))
|
||||||
|
}
|
||||||
|
|
||||||
val dockerEnvUpdate by tasks.registering(DockerEnvUpdateTask::class) {
|
tasks.dockerComposeEnvUpdate {
|
||||||
dotEnvFile.set(layout.projectDirectory.file("docker/.env"))
|
|
||||||
|
|
||||||
properties(
|
properties(
|
||||||
"COMPOSE_PROJECT_NAME" to rootProject.name,
|
|
||||||
"KAFKATORIO_VERSION" to project.version,
|
"KAFKATORIO_VERSION" to project.version,
|
||||||
"REGISTRY_HOST" to "dcr.adamko.dev:5000",
|
"REGISTRY_HOST" to "dcr.adamko.dev:5000",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
tasks.assemble { dependsOn(dockerEnvUpdate) }
|
|
||||||
|
tasks.assemble { dependsOn(tasks.dockerComposeEnvUpdate) }
|
||||||
|
|
||||||
|
|
||||||
val installThemeCss by tasks.registering(Copy::class) {
|
val installThemeCss by tasks.registering(Copy::class) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue