2021-12-01 18:12:34 +01:00
|
|
|
import dev.adamko.kafkatorio.gradle.asProvider
|
|
|
|
|
import dev.adamko.kafkatorio.gradle.typescriptAttributes
|
2022-06-26 14:56:53 +02:00
|
|
|
import dev.adamko.kafkatorio.task.GenerateTypeScriptTask
|
2022-07-05 23:44:23 +02:00
|
|
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
|
|
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmCompilation
|
|
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2022-02-09 13:16:57 +01:00
|
|
|
|
2021-10-22 18:17:48 +02:00
|
|
|
plugins {
|
2022-02-09 13:16:57 +01:00
|
|
|
dev.adamko.kafkatorio.lang.`kotlin-multiplatform`
|
2022-02-09 11:53:58 +01:00
|
|
|
id("io.kotest.multiplatform")
|
2022-02-09 13:16:57 +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
|
|
|
|
2022-02-09 13:16:57 +01:00
|
|
|
|
2022-07-01 13:14:32 +02:00
|
|
|
description = "shared data structures and utilities"
|
|
|
|
|
|
|
|
|
|
|
2021-12-08 17:43:08 +01:00
|
|
|
kotlin {
|
2022-04-19 23:25:10 +02:00
|
|
|
|
2021-12-08 17:43:08 +01:00
|
|
|
js(IR) {
|
2022-06-19 10:21:59 +02:00
|
|
|
browser {}
|
2022-06-26 14:56:53 +02:00
|
|
|
// this is a library - don't set binaries.executable()
|
2021-12-08 17:43:08 +01:00
|
|
|
}
|
2022-01-09 11:06:15 +01:00
|
|
|
jvm {
|
2022-04-19 23:25:10 +02:00
|
|
|
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.ExperimentalStdlibApi")
|
2022-07-05 23:44:23 +02:00
|
|
|
optIn("kotlin.ExperimentalUnsignedTypes")
|
2022-07-02 10:21:13 +02:00
|
|
|
optIn("kotlin.RequiresOptIn")
|
|
|
|
|
optIn("kotlin.js.ExperimentalJsExport")
|
2021-12-08 17:43:08 +01:00
|
|
|
optIn("kotlin.time.ExperimentalTime")
|
2022-07-02 10:21:13 +02:00
|
|
|
optIn("kotlinx.coroutines.FlowPreview")
|
2021-12-08 17:43:08 +01:00
|
|
|
optIn("kotlinx.serialization.ExperimentalSerializationApi")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
2022-07-05 23:44:23 +02:00
|
|
|
api(libs.kxs.kxsTsGen)
|
2022-07-02 08:45:21 +02:00
|
|
|
|
|
|
|
|
implementation(dependencies.platform(libs.okio.bom))
|
|
|
|
|
implementation(libs.okio.core)
|
|
|
|
|
|
|
|
|
|
implementation(dependencies.platform(libs.kotlinx.coroutines.bom))
|
|
|
|
|
implementation(libs.kotlinx.coroutines.core)
|
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))
|
2022-05-14 12:23:58 +02:00
|
|
|
implementation(libs.kotest.core)
|
|
|
|
|
implementation(libs.kotest.datatest)
|
2022-07-06 16:20:11 +02:00
|
|
|
implementation(libs.kotest.frameworkEngine)
|
2022-05-14 12:23:58 +02:00
|
|
|
implementation(libs.kotest.json)
|
2022-07-06 16:20:11 +02:00
|
|
|
implementation(libs.kotest.prop)
|
2021-12-08 17:43:08 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2021-12-08 17:43:08 +01:00
|
|
|
val jvmMain by getting {
|
|
|
|
|
dependencies {
|
2022-04-19 23:25:10 +02:00
|
|
|
implementation(kotlin("reflect"))
|
2021-12-08 17:43:08 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-03 09:04:18 +01:00
|
|
|
|
2021-12-08 17:43:08 +01:00
|
|
|
val jvmTest by getting {
|
|
|
|
|
dependencies {
|
2022-07-06 16:20:11 +02:00
|
|
|
implementation(libs.kotest.runnerJunit5)
|
2021-12-08 17:43:08 +01:00
|
|
|
}
|
|
|
|
|
}
|
2022-02-13 10:44:13 +01:00
|
|
|
|
|
|
|
|
val jsTest by getting {
|
|
|
|
|
dependencies {
|
2022-07-06 16:20:11 +02:00
|
|
|
// implementation(kotlin("test-js"))
|
2022-02-13 10:44:13 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-08 17:43:08 +01:00
|
|
|
}
|
2021-10-31 09:13:41 +01:00
|
|
|
}
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2022-07-02 10:21:13 +02:00
|
|
|
|
2022-07-05 23:44:23 +02:00
|
|
|
val kotlinJvmMainCompilation: NamedDomainObjectProvider<KotlinJvmCompilation> =
|
|
|
|
|
kotlin.jvm().compilations.named(KotlinCompilation.MAIN_COMPILATION_NAME)
|
|
|
|
|
|
|
|
|
|
|
2022-05-07 20:22:54 +02:00
|
|
|
val jvmJar: TaskProvider<Jar> = tasks.named<Jar>(kotlin.jvm().artifactsTaskName)
|
2022-07-05 23:44:23 +02:00
|
|
|
|
|
|
|
|
val kotlinMainRuntimeDependencies: Provider<FileCollection> =
|
|
|
|
|
kotlinJvmMainCompilation.map { it.runtimeDependencyFiles }
|
|
|
|
|
|
|
|
|
|
val kotlinMainCompileDependencies: Provider<FileCollection> =
|
|
|
|
|
kotlinJvmMainCompilation.map { it.compileDependencyFiles }
|
|
|
|
|
|
|
|
|
|
val kotlinMainCompileTask: Provider<KotlinCompile> =
|
|
|
|
|
kotlinJvmMainCompilation.map { it.compileKotlinTask }
|
2021-12-08 17:43:08 +01:00
|
|
|
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2022-06-26 14:56:53 +02:00
|
|
|
val generateTypeScript by tasks.registering(GenerateTypeScriptTask::class) {
|
2022-04-23 17:59:37 +02:00
|
|
|
dependsOn(jvmJar)
|
2022-07-05 23:44:23 +02:00
|
|
|
// dependsOn(kotlinMainCompileTask)
|
|
|
|
|
|
|
|
|
|
// inputs.files(jvmJar.map { it.outputs.files })
|
|
|
|
|
// inputs.files(kotlinMainCompileTask.map { it.javaSources })
|
|
|
|
|
|
2021-12-08 17:43:08 +01:00
|
|
|
classpath(
|
|
|
|
|
jvmJar,
|
2022-07-05 23:44:23 +02:00
|
|
|
kotlinMainRuntimeDependencies,
|
|
|
|
|
// kotlinMainCompileTask.map { it.libraries }
|
|
|
|
|
// kotlinMainDependencies,
|
2021-12-08 17:43:08 +01:00
|
|
|
)
|
2022-05-07 20:22:54 +02:00
|
|
|
output.set(layout.buildDirectory.dir("generated/typescript"))
|
2022-04-19 23:25:10 +02:00
|
|
|
mainClass.set("dev.adamko.kafkatorio.events.schema.Kt2ts2Kt")
|
2022-05-07 20:22:54 +02:00
|
|
|
args(temporaryDir.canonicalPath)
|
|
|
|
|
}
|
2021-12-08 17:43:08 +01:00
|
|
|
|
2022-07-02 10:21:13 +02:00
|
|
|
|
2022-06-19 10:21:59 +02:00
|
|
|
val schemaTsDistributionName: Provider<String> = providers.provider {
|
2022-05-07 20:22:54 +02:00
|
|
|
"${rootProject.name}-${project.name}"
|
2021-12-02 00:54:15 +01:00
|
|
|
}
|
|
|
|
|
|
2022-07-02 10:21:13 +02:00
|
|
|
|
2022-06-26 14:56:53 +02:00
|
|
|
val generateTypeScriptOutputFiles: Provider<FileTree> =
|
|
|
|
|
generateTypeScript.map { it.outputs.files.asFileTree }
|
2022-05-14 12:23:58 +02:00
|
|
|
|
2022-07-02 10:21:13 +02:00
|
|
|
|
2022-07-05 23:44:23 +02:00
|
|
|
//val schemaTs by distributions.registering {
|
|
|
|
|
// distributionBaseName.set(schemaTsDistributionName)
|
|
|
|
|
// contents {
|
|
|
|
|
// from(generateTypeScriptOutputFiles)
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
2021-11-10 17:34:01 +01:00
|
|
|
|
2022-07-05 23:44:23 +02:00
|
|
|
//val schemaTsZipTask: TaskProvider<Zip> = tasks.named<Zip>("${schemaTs.name}DistZip")
|
|
|
|
|
//val schemaTsZipTaskArchiveFile: Provider<RegularFile> = schemaTsZipTask.flatMap { it.archiveFile }
|
2022-07-02 10:21:13 +02:00
|
|
|
|
2022-07-05 23:44:23 +02:00
|
|
|
|
|
|
|
|
val schemaTsZip by tasks.registering(Zip::class) {
|
|
|
|
|
group = "kt2ts"
|
|
|
|
|
|
|
|
|
|
archiveBaseName.set("schema-ts")
|
|
|
|
|
from(generateTypeScriptOutputFiles)
|
|
|
|
|
destinationDirectory.set(layout.buildDirectory.dir("distributions/kt2ts"))
|
|
|
|
|
}
|
|
|
|
|
val schemaTsZipTaskArchiveFile: Provider<RegularFile> = schemaTsZip.flatMap { it.archiveFile }
|
2022-05-07 20:22:54 +02:00
|
|
|
|
2022-07-02 10:21:13 +02:00
|
|
|
|
2022-06-26 14:56:53 +02:00
|
|
|
val typeScriptModelGenerated: Configuration by configurations.creating {
|
2021-11-27 17:57:50 +01:00
|
|
|
asProvider()
|
|
|
|
|
typescriptAttributes(objects)
|
2021-12-08 17:43:08 +01:00
|
|
|
|
2022-05-14 12:23:58 +02:00
|
|
|
outgoing.artifact(schemaTsZipTaskArchiveFile)
|
2022-07-05 23:44:23 +02:00
|
|
|
// outgoing.artifact(schemaTsZipTaskArchiveFile)
|
2021-11-27 17:57:50 +01:00
|
|
|
}
|