Kafkatorio/modules/events-schema/build.gradle.kts

117 lines
2.8 KiB
Text
Raw Normal View History

2021-12-01 18:12:34 +01:00
import dev.adamko.kafkatorio.gradle.asProvider
import dev.adamko.kafkatorio.gradle.typescriptAttributes
plugins {
2021-12-08 17:43:08 +01:00
kotlin("multiplatform")
kotlin("plugin.serialization")
distribution
}
2021-10-25 23:35:18 +02:00
2021-12-08 17:43:08 +01:00
kotlin {
js(IR) {
binaries.executable()
nodejs()
}
jvm()
@Suppress("UnstableApiUsage") // enforcedPlatform is incubating
sourceSets {
all {
languageSettings.apply {
optIn("kotlin.RequiresOptIn")
optIn("kotlin.ExperimentalStdlibApi")
optIn("kotlin.time.ExperimentalTime")
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
2021-12-08 17:43:08 +01:00
optIn("kotlinx.serialization.ExperimentalSerializationApi")
2021-12-08 21:15:37 +01:00
optIn("kotlin.js.ExperimentalJsExport")
2021-12-08 17:43:08 +01:00
}
}
val commonMain by getting {
dependencies {
2022-01-04 15:09:50 +01:00
implementation(project.dependencies.platform(libs.kotlin.bom))
2021-12-08 17:43:08 +01:00
2022-01-04 15:09:50 +01:00
implementation(project.dependencies.platform(libs.kotlinx.serialization.bom))
2021-12-08 17:43:08 +01:00
implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
2022-01-04 15:09:50 +01:00
implementation(project.dependencies.platform(libs.kotest.bom))
2021-12-08 17:43:08 +01:00
implementation("io.kotest:kotest-assertions-core")
implementation("io.kotest:kotest-property")
implementation("io.kotest:kotest-assertions-json")
}
}
2021-12-08 17:43:08 +01:00
val jvmMain by getting {
dependencies {
implementation("com.github.aSemy:ts-generator:v1.2.1")
// implementation("com.github.ntrrgc:ts-generator:1.1.2")
2021-12-08 17:43:08 +01:00
implementation("org.jetbrains.kotlin:kotlin-reflect")
}
}
2021-12-08 17:43:08 +01:00
val jvmTest by getting {
dependencies {
implementation("io.kotest:kotest-runner-junit5")
}
}
}
2021-10-31 09:13:41 +01:00
}
2021-12-08 17:43:08 +01:00
val generateTypescript by tasks.registering(JavaExec::class) {
group = project.name
2021-12-08 17:43:08 +01:00
val jvmJar by tasks.getting(Jar::class)
val main by kotlin.jvm().compilations.getting
classpath(
jvmJar,
main.runtimeDependencyFiles
)
mainClass.set("dev.adamko.kafkatorio.events.schema.Kt2tsKt")
2021-12-08 17:43:08 +01:00
val tempOutputDirectory = file("$temporaryDir")
args(tempOutputDirectory)
val buildOutput = layout.buildDirectory.dir("generated/typescript")
outputs.dir(buildOutput)
doFirst {
delete(temporaryDir)
mkdir(temporaryDir)
}
doLast {
2021-12-08 17:43:08 +01:00
sync {
from(temporaryDir)
into(buildOutput)
include("**/*.ts")
}
}
}
2021-12-08 17:43:08 +01:00
val schemaTs by distributions.registering {
distributionBaseName.set("${rootProject.name}-${project.name}")
contents {
from(generateTypescript.map { it.outputs.files.asFileTree })
}
}
2021-12-08 17:43:08 +01:00
val typescriptModelGenerated : Configuration by configurations.creating {
asProvider()
typescriptAttributes(objects)
2021-12-08 17:43:08 +01:00
val schemaTsZipTask = tasks.named<Zip>("${schemaTs.name}DistZip")
outgoing.artifact(schemaTsZipTask.flatMap { it.archiveFile })
}