2021-12-01 18:12:34 +01:00
|
|
|
import dev.adamko.kafkatorio.gradle.asProvider
|
|
|
|
|
import dev.adamko.kafkatorio.gradle.typescriptAttributes
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2021-10-22 18:17:48 +02:00
|
|
|
plugins {
|
2021-12-01 18:12:34 +01:00
|
|
|
id("dev.adamko.kafkatorio.lang.kotlin-jvm")
|
2021-11-10 17:34:01 +01:00
|
|
|
kotlin("plugin.serialization")
|
2021-12-02 00:54:15 +01:00
|
|
|
distribution
|
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-12-02 00:54:15 +01:00
|
|
|
val generatedFile = file("$temporaryDir/${project.name}.ts")
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2021-11-27 17:57:50 +01:00
|
|
|
classpath(sourceSets.main.map { it.runtimeClasspath })
|
2021-12-02 00:54:15 +01:00
|
|
|
mainClass.set("dev.adamko.kafkatorio.events.schema.Kt2tsKt")
|
|
|
|
|
args(generatedFile)
|
|
|
|
|
|
|
|
|
|
val buildOutput = layout.buildDirectory.dir("generated/typescript")
|
|
|
|
|
outputs.dir(buildOutput)
|
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-12-02 00:54:15 +01:00
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
|
sync { from(temporaryDir); into(buildOutput) }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
distributions {
|
|
|
|
|
main {
|
|
|
|
|
distributionBaseName.set("${rootProject.name}-${project.name}")
|
|
|
|
|
contents {
|
|
|
|
|
from(generateTypescript.map { it.outputs.files.asFileTree })
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-10 17:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-27 17:57:50 +01:00
|
|
|
val typescriptModelGenerated by configurations.registering {
|
|
|
|
|
asProvider()
|
|
|
|
|
typescriptAttributes(objects)
|
2021-12-02 00:54:15 +01:00
|
|
|
outgoing.artifact(tasks.distZip.flatMap { it.archiveFile })
|
2021-11-27 17:57:50 +01:00
|
|
|
}
|