Initial version (Server, Compose clients work)
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
@file:OptIn(ExperimentalWasmDsl::class)
|
||||
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
alias(libs.plugins.serialization)
|
||||
}
|
||||
|
||||
val partialsDirectory = layout.buildDirectory.dir("generated/sources/partials")
|
||||
val versionDirectory = layout.buildDirectory.dir("generated/sources/version")
|
||||
val requestsDirectory = layout.projectDirectory.dir("src/commonMain/kotlin/com/jaytux/phoebench/common/")
|
||||
|
||||
val generatePartials = tasks.register<Exec>("generatePartials") {
|
||||
group = "generation"
|
||||
description = "Generate Partial classes (requests with all-nullable fields)"
|
||||
val scriptFile = project.file("partialize.main.kts")
|
||||
val targets = fileTree(requestsDirectory) {
|
||||
include("**/*.kt")
|
||||
}
|
||||
val lst = targets.map { it.absolutePath }
|
||||
|
||||
inputs.file(scriptFile)
|
||||
inputs.files(targets)
|
||||
outputs.dir(partialsDirectory)
|
||||
executable = "kotlin"
|
||||
doFirst {
|
||||
args(scriptFile.absolutePath, partialsDirectory.get().asFile.absolutePath, *lst.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
val generateVersion = tasks.register<Task>("protocolVersion") {
|
||||
doFirst {
|
||||
val outFile = versionDirectory.get().file("com/jaytux/phoebench/common/Version.kt").asFile
|
||||
outFile.parentFile.mkdirs()
|
||||
outFile.writeText("""
|
||||
package com.jaytux.phoebench.common
|
||||
|
||||
object ProtocolVersion {
|
||||
const val VERSION="${rootProject.version}"
|
||||
}
|
||||
""".trimIndent())
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm("desktop")
|
||||
wasmJs {
|
||||
browser()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
kotlin {
|
||||
srcDir(generatePartials)
|
||||
srcDir(versionDirectory)
|
||||
}
|
||||
dependencies {
|
||||
implementation(libs.ktor.client.core)
|
||||
implementation(libs.ktor.client.auth)
|
||||
implementation(libs.kotlinx.datetime)
|
||||
implementation(libs.kotlinx.serialization)
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targets.all {
|
||||
compilations.all {
|
||||
compileTaskProvider.configure {
|
||||
dependsOn(generatePartials)
|
||||
dependsOn(generateVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compilerOptions {
|
||||
freeCompilerArgs.add("-Xcontext-parameters")
|
||||
optIn.add("kotlin.uuid.ExperimentalUuidApi")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user