Skip to content

Commit

Permalink
Convert model module to be multiplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
JPercival committed Dec 30, 2024
1 parent 236d5cc commit dd5099d
Show file tree
Hide file tree
Showing 46 changed files with 70 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ node {
}

val buildDir = project.layout.buildDirectory.get().toString()
val destDir = "${buildDir}/generated/sources/$name/main/java"
val destDir = "${buildDir}/generated/sources/$name/main/kotlin"

val runXsdKotlinGenTask = tasks.register<NodeTask>("runXsdKotlinGen") {
dependsOn(tasks.npmInstall)
Expand All @@ -43,7 +43,7 @@ tasks.withType<Delete>().configureEach {

sourceSets {
main {
java {
kotlin {
srcDir(destDir)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.github.gradle.node.task.NodeTask
import gradle.kotlin.dsl.accessors._2dcd0a84416f85634c85a37519569374.sourceSets
import org.gradle.kotlin.dsl.kotlin

plugins {
id("cql.kotlin-multiplatform-conventions")
kotlin("plugin.serialization")
id("com.github.node-gradle.node")
}

val buildDir = project.layout.buildDirectory.get().toString()
val destDir = "${buildDir}/generated/sources/$name/commonMain/kotlin"

kotlin {
sourceSets {
commonMain {
kotlin {
srcDir(destDir)
}
dependencies {
implementation("io.github.pdvrieze.xmlutil:core:0.90.3")
implementation("io.github.pdvrieze.xmlutil:serialization:0.90.3")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0")
}
}

jvmMain {
dependencies {
implementation("io.github.pdvrieze.xmlutil:serialization-jvm:0.90.3")
}
}
}
}

node {
download = true
nodeProjectDir.set(file("../../js/xsd-kotlin-gen"))
}

val runXsdKotlinGenTask = tasks.register<NodeTask>("runXsdKotlinGen") {
dependsOn(tasks.npmInstall)
script.set(file("../../js/xsd-kotlin-gen/generate.js"))
}

tasks.withType<KotlinCompile>().configureEach {
dependsOn(runXsdKotlinGenTask)
}

tasks.withType<JavaCompile>().configureEach {
dependsOn(runXsdKotlinGenTask)
}

tasks.withType<Delete>().configureEach {
delete(destDir)
}
19 changes: 9 additions & 10 deletions Src/java/model/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
plugins {
id("cql.library-conventions")
id("cql.xjc-temp-conventions")
id("cql.xsd-kotlin-gen-conventions")
id("cql.xsd-kotlin-multiplatform-gen-conventions")
}

tasks.register<XjcTask>("generateModel") {
schema = "${projectDir}/../../cql-lm/schema/model/modelinfo.xsd"
extraArgs = listOf("-npa")
}

dependencies {
// circular dependency
testImplementation(project(":model-xmlutil"))
kotlin {
sourceSets {
jvmTest {
dependencies {
implementation(project(":model-xmlutil"))
}
}
}
}
6 changes: 3 additions & 3 deletions Src/js/xsd-kotlin-gen/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const configs = [
xsd: __dirname + "/../../cql-lm/schema/model/modelinfo.xsd",
outputDir:
__dirname +
"/../../java/model/build/generated/sources/model/main/java/org/hl7/elm_modelinfo/r1",
"/../../java/model/build/generated/sources/model/commonMain/kotlin/org/hl7/elm_modelinfo/r1",
packageName: "org.hl7.elm_modelinfo.r1",
classes: {},
scope: "",
Expand All @@ -184,7 +184,7 @@ const configs = [
xsd: __dirname + "/../../cql-lm/schema/elm/library.xsd",
outputDir:
__dirname +
"/../../java/elm/build/generated/sources/elm/main/java/org/hl7/elm/r1",
"/../../java/elm/build/generated/sources/elm/main/kotlin/org/hl7/elm/r1",
packageName: "org.hl7.elm.r1",
// autoExtend: "org.cqframework.cql.elm.tracking.Trackable",
classes: {},
Expand All @@ -205,7 +205,7 @@ const configs = [
xsd: __dirname + "/../../cql-lm/schema/elm/cqlannotations.xsd",
outputDir:
__dirname +
"/../../java/elm/build/generated/sources/elm/main/java/org/hl7/cql_annotations/r1",
"/../../java/elm/build/generated/sources/elm/main/kotlin/org/hl7/cql_annotations/r1",
packageName: "org.hl7.cql_annotations.r1",
classes: {},
scope: "narrative",
Expand Down

0 comments on commit dd5099d

Please sign in to comment.