54 lines
1.4 KiB
Kotlin
54 lines
1.4 KiB
Kotlin
import dev.adamko.kafkatorio.gradle.asProvider
|
|
import dev.adamko.kafkatorio.gradle.typescriptAttributes
|
|
|
|
plugins {
|
|
id("dev.adamko.kafkatorio.lang.kotlin-jvm")
|
|
kotlin("plugin.serialization")
|
|
distribution
|
|
}
|
|
|
|
dependencies {
|
|
implementation(platform(libs.kotlinx.serialization.bom))
|
|
implementation(libs.kotlinx.serialization.core)
|
|
implementation(libs.kotlinx.serialization.json)
|
|
|
|
implementation("com.github.ntrrgc:ts-generator:1.1.2")
|
|
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
|
}
|
|
|
|
val generateTypescript by tasks.registering(JavaExec::class) {
|
|
group = project.name
|
|
|
|
val generatedFile = file("$temporaryDir/${project.name}.ts")
|
|
|
|
classpath(sourceSets.main.map { it.runtimeClasspath })
|
|
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(tasks.distZip.flatMap { it.archiveFile })
|
|
}
|