2021-11-27 17:57:50 +01:00
|
|
|
import dev.adamko.factoriowebmap.configurations.asProvider
|
|
|
|
|
import dev.adamko.factoriowebmap.configurations.typescriptAttributes
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2021-10-22 18:17:48 +02:00
|
|
|
plugins {
|
2021-11-27 17:57:50 +01:00
|
|
|
id("dev.adamko.factoriowebmap.archetype.kotlin-jvm")
|
2021-11-10 17:34:01 +01:00
|
|
|
kotlin("plugin.serialization")
|
2021-10-29 19:14:47 +02:00
|
|
|
}
|
2021-10-25 23:35:18 +02:00
|
|
|
|
2021-11-27 17:57:50 +01:00
|
|
|
dependencies {
|
2021-12-01 13:35:32 +01:00
|
|
|
implementation(platform(libs.kotlinx.serialization.bom))
|
|
|
|
|
implementation(libs.kotlinx.serialization.core)
|
|
|
|
|
implementation(libs.kotlinx.serialization.json)
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2021-11-27 17:57:50 +01:00
|
|
|
implementation("com.github.ntrrgc:ts-generator:1.1.2")
|
|
|
|
|
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
2021-10-31 09:13:41 +01:00
|
|
|
}
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2021-11-27 17:57:50 +01:00
|
|
|
val generateTypescript by tasks.registering(JavaExec::class) {
|
|
|
|
|
group = project.name
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2021-11-27 17:57:50 +01:00
|
|
|
val generatedFileName = "$temporaryDir/data-model.ts"
|
|
|
|
|
inputs.property("generatedFileName", generatedFileName)
|
|
|
|
|
outputs.file(generatedFileName)
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2021-11-27 17:57:50 +01:00
|
|
|
classpath(sourceSets.main.map { it.runtimeClasspath })
|
|
|
|
|
mainClass.set("dev.adamko.factorioevents.model.Kt2tsKt")
|
|
|
|
|
args(generatedFileName)
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2021-11-27 17:57:50 +01:00
|
|
|
doFirst {
|
|
|
|
|
delete(temporaryDir)
|
|
|
|
|
mkdir(temporaryDir)
|
2021-11-10 17:34:01 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-27 17:57:50 +01:00
|
|
|
val typescriptModelGenerated by configurations.registering {
|
|
|
|
|
asProvider()
|
|
|
|
|
typescriptAttributes(objects)
|
|
|
|
|
outgoing.artifact(
|
|
|
|
|
generateTypescript.map {
|
|
|
|
|
it.outputs.files.singleFile
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|