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

158 lines
4 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
dev.adamko.kafkatorio.lang.`kotlin-multiplatform`
id("io.kotest.multiplatform")
kotlin("plugin.serialization")
distribution
}
2021-10-25 23:35:18 +02:00
2021-12-08 17:43:08 +01:00
kotlin {
2021-12-08 17:43:08 +01:00
js(IR) {
binaries.executable()
// browser{} causes this error:
// Cannot load "webpack", it is not registered!
// Perhaps you are missing some plugin?
// Cannot load "sourcemap", it is not registered!
// Perhaps you are missing some plugin?
// Server start failed on port 9876: Error: No provider for "framework:mocha"! (Resolving: framework:mocha)
// browser {
// runTask {
// sourceMaps = true
// }
// testTask {
// useKarma {
// useChromeHeadless()
// }
// }
// }
nodejs()
2021-12-08 17:43:08 +01:00
}
2022-01-09 11:06:15 +01:00
jvm {
val main by compilations.getting {
kotlinOptions {
jvmTarget = "11"
}
}
2022-01-09 11:06:15 +01:00
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
2021-12-08 17:43:08 +01:00
sourceSets {
all {
languageSettings.apply {
optIn("kotlin.RequiresOptIn")
optIn("kotlin.ExperimentalStdlibApi")
optIn("kotlin.time.ExperimentalTime")
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)
api("dev.adamko.kxtsgen:kxs-ts-gen-core:dev-SNAPSHOT")
// implementation("com.github.adamko-dev:kotlinx-serialization-typescript-generator:dev-SNAPSHOT") {
// isChanging = true
// }
2021-12-08 17:43:08 +01:00
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
2022-01-04 15:09:50 +01:00
implementation(project.dependencies.platform(libs.kotest.bom))
implementation("io.kotest:kotest-framework-engine")
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")
implementation(kotlin("reflect"))
// implementation("com.github.adamko-dev:kotlinx-serialization-typescript-generator:0.0.5")
2021-12-08 17:43:08 +01:00
}
}
2021-12-08 17:43:08 +01:00
val jvmTest by getting {
dependencies {
implementation("io.kotest:kotest-runner-junit5")
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
2021-12-08 17:43:08 +01:00
}
2021-10-31 09:13:41 +01:00
}
2021-12-08 17:43:08 +01:00
val generateTypescript by tasks.registering(JavaExec::class) {
group = "kt2ts"
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")
mainClass.set("dev.adamko.kafkatorio.events.schema.Kt2ts2Kt")
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 })
}
}
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 })
}