-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: kotlin multi-platform [DHIS2-16221] (#116)
* chore: RuleContent and RuleEffects as records * chore: RuleEvaluationResult as record * chore: RuleValidationResult as record * chore: removed unused TimeInterval * chore: DataItem as record * chore: RuleEngineExecution as record * chore: RuleEngineMultipleExecution as record * chore: RuleVariableValue as record * chore: RuleEnrollment, RuleEvent as record * chore: removed unused class SupplementaryData * chore: RuleEngine as record * chore: RuleVariableValueMap as record * chore: cleanup RuleVariableValueMapBuilder * chore: RuleAction hierarchy as records * chore: RuleDataValue as record * chore: general cleanup * chore: RuleVariable hierarchy as records and interfaces * chore: RuleAttributeValue as record * chore: RuleActionAttribute hierarchy to records * chore: general cleanuo * chore: test cleanup * chore: removed unused dependency * chore: remove common lang dependency * chore: replace joda time with java.time * chore: removed equalsverifier dependency * chore: replaced assertj with vanilla junit * chore: replace @nullable with @checkfornull * chore: removed mockito dependency * chore: replace slf4j with java.util.logging * chore: removed apache commons dependency * chore: replace Arrays.asList with List.of * chore: replace Arrays.asList with List.of * chore: general cleanup * chore: use KMP expression parser snapshot * refactor: RuleEngine, RuleValidationResult, AttributeType to kotlin * refactor: RuleEngineTest to kotlin * refactor: RuleActionHideField to kotlin * refactor RuleActionHideProgramStage to kotlin * refactor enums to kotlin * refactor rule effects to kotlin * put list of envs back * Update github actions * refactor utils to kotlin * refactor option and dataItem to kotlin * refactor ruleVariableValueMap to kotlin * refactor ruleVariableValueMap to kotlin * refactor Rule to kotlin and all related tests * refactor RuleEvent to kotlin * refactor RuleEngineContext to kotlin * refactor RuleEnrollment to kotlin * refactor RuleVariable to kotlin * Make data for RuleEffect optional * refactor RuleVariableValue to kotlin * refactor hide actions to kotlin * refactor more actions to kotlin * refactor send actions to kotlin * refactor mandatory action to kotlin * refactor message action to kotlin * refactor rule values to kotlin * refactor assign action to kotlin * last conversions to kotlin * Allow null data for actions * Add type for text actions * Bump shanpshot version * Create KMP structure * Remove java.util.Callable usages * Remove java.util.Map usages * Remove Logger and Dates usages * Move implementation to common * Move tests to common * Move tests to common * refactor: Clean up description call to rule engine (#117) * refactor: Clean up description call to rule engine * refactor: Clean up evaluation call to rule engine * refactor: Clean up evaluation call to rule engine * refactor: EventDate changed from LocalDate to Instant * Refactor package structure * Refactor package structure * Fix RuleAction interface * Fix RuleAction interface * Fix RuleEngine API interface * Make engine package internal * Make rule engine getInstance static for Java * Update build.gradle.kts --------- Co-authored-by: Enrico <[email protected]> Co-authored-by: Victor Garcia <[email protected]>
- Loading branch information
1 parent
86c2617
commit c5c7085
Showing
191 changed files
with
8,671 additions
and
10,988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
plugins { | ||
kotlin("multiplatform") | ||
id("maven-publish-conventions") | ||
id("npm-publish-conventions") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } | ||
} | ||
|
||
group = "org.hisp.dhis.rules" | ||
version = "3.0.0-SNAPSHOT" | ||
|
||
val isReleaseVersion = project.hasProperty("removeSnapshot") | ||
if (isReleaseVersion) { | ||
version = (version as String).replace("-SNAPSHOT", "") | ||
} | ||
|
||
kotlin { | ||
jvm { | ||
jvmToolchain(17) | ||
withJava() | ||
testRuns.named("test") { | ||
executionTask.configure { | ||
useJUnit() | ||
} | ||
} | ||
} | ||
js { | ||
nodejs() | ||
useEsModules() | ||
binaries.library() | ||
generateTypeScriptDefinitions() | ||
} | ||
val hostOs = System.getProperty("os.name") | ||
val isArm64 = System.getProperty("os.arch") == "aarch64" | ||
val isMingwX64 = hostOs.startsWith("Windows") | ||
val nativeTarget = when { | ||
hostOs == "Mac OS X" && isArm64 -> macosArm64("native") | ||
hostOs == "Mac OS X" && !isArm64 -> macosX64("native") | ||
hostOs == "Linux" && isArm64 -> linuxArm64("native") | ||
hostOs == "Linux" && !isArm64 -> linuxX64("native") | ||
isMingwX64 -> mingwX64("native") | ||
else -> throw GradleException("Host OS is not supported in Kotlin/Native.") | ||
} | ||
|
||
|
||
sourceSets { | ||
val commonMain by getting { | ||
dependencies { | ||
implementation("org.hisp.dhis.lib.expression:expression-parser:1.1.0-SNAPSHOT") | ||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") | ||
} | ||
} | ||
val commonTest by getting { | ||
dependencies { | ||
implementation(kotlin("test")) | ||
} | ||
} | ||
val jvmMain by getting | ||
val jvmTest by getting | ||
val jsMain by getting | ||
val jsTest by getting | ||
val nativeMain by getting | ||
val nativeTest by getting | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
val kotlinVersion = "1.9.21" | ||
val dokkaVersion = "1.9.10" | ||
val nexusPluginVersion = "1.3.0" | ||
val npmPluginVersion = "3.4.1" | ||
|
||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") | ||
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${dokkaVersion}") | ||
implementation("io.github.gradle-nexus:publish-plugin:${nexusPluginVersion}") | ||
implementation("dev.petuska:npm-publish-gradle-plugin:${npmPluginVersion}") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
object Props { | ||
const val DESCRIPTION = "Rule Engine" | ||
|
||
const val REPOSITORY_TYPE = "git" | ||
const val REPOSITORY_SYSTEM = "GitHub" | ||
const val REPOSITORY_URL = "https://github.com/dhis2/dhis2-rule-engine.git" | ||
|
||
const val ORGANIZATION_NAME = "UiO" | ||
const val ORGANIZATION_URL = "https://dhis2.org" | ||
|
||
const val LICENSE_NAME = "BSD-3-Clause" | ||
const val LICENSE_URL = "https://opensource.org/license/bsd-3-clause/" | ||
|
||
val DEVELOPERS = listOf( | ||
Developer( | ||
name = "Enrico Colasante", | ||
email = "[email protected]", | ||
organization = "UiO", | ||
organizationUrl = "https://www.uio.no/" | ||
), | ||
Developer( | ||
name = "Zubair Asghar", | ||
email = "[email protected]", | ||
organization = "UiO", | ||
organizationUrl = "https://www.uio.no/" | ||
), | ||
) | ||
} | ||
|
||
data class Developer( | ||
val name: String, | ||
val email: String, | ||
val organization: String, | ||
val organizationUrl: String, | ||
) |
76 changes: 76 additions & 0 deletions
76
buildSrc/src/main/kotlin/maven-publish-conventions.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
plugins { | ||
`maven-publish` | ||
signing | ||
id("io.github.gradle-nexus.publish-plugin") | ||
id("org.jetbrains.dokka") | ||
} | ||
|
||
val ossrhUsername: String? = System.getenv("OSSRH_USERNAME") | ||
val ossrhPassword: String? = System.getenv("OSSRH_PASSWORD") | ||
val signingPrivateKey: String? = System.getenv("SIGNING_PRIVATE_KEY") | ||
val signingPassword: String? = System.getenv("SIGNING_PASSWORD") | ||
|
||
val isReleaseVersion = (version as String).contains("SNAPSHOT") | ||
|
||
val dokkaHtml = tasks.findByName("dokkaHtml")!! | ||
|
||
val dokkaHtmlJar = tasks.register<Jar>("dokkaHtmlJar") { | ||
dependsOn(dokkaHtml) | ||
from(dokkaHtml.outputs) | ||
archiveClassifier.set("docs") | ||
} | ||
|
||
publishing { | ||
publications.withType<MavenPublication> { | ||
artifact(dokkaHtmlJar) | ||
|
||
pom { | ||
name.set("rule-engine") | ||
description.set(Props.DESCRIPTION) | ||
|
||
organization { | ||
name.set(Props.ORGANIZATION_NAME) | ||
url.set(Props.ORGANIZATION_URL) | ||
} | ||
developers { | ||
Props.DEVELOPERS.map { | ||
developer { | ||
name.set(it.name) | ||
email.set(it.email) | ||
organization.set(it.organization) | ||
organizationUrl.set(it.organizationUrl) | ||
} | ||
} | ||
} | ||
licenses { | ||
license { | ||
name.set(Props.LICENSE_NAME) | ||
url.set(Props.LICENSE_URL) | ||
} | ||
} | ||
scm { | ||
url.set("lp:dhis2") | ||
} | ||
issueManagement { | ||
system.set(Props.REPOSITORY_SYSTEM) | ||
url.set(Props.REPOSITORY_URL) | ||
} | ||
url.set(Props.REPOSITORY_URL) | ||
} | ||
} | ||
} | ||
|
||
nexusPublishing { | ||
this.repositories { | ||
sonatype { | ||
username.set(ossrhUsername) | ||
password.set(ossrhPassword) | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
isRequired = isReleaseVersion | ||
useInMemoryPgpKeys(signingPrivateKey, signingPassword) | ||
sign(publishing.publications) | ||
} |
52 changes: 52 additions & 0 deletions
52
buildSrc/src/main/kotlin/npm-publish-conventions.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import dev.petuska.npm.publish.extension.domain.NpmAccess | ||
|
||
plugins { | ||
id("dev.petuska.npm.publish") | ||
} | ||
|
||
val npmjsToken: String? = System.getenv("NPMJS_TOKEN") | ||
|
||
project.afterEvaluate { | ||
npmPublish { | ||
access.set(NpmAccess.PUBLIC) | ||
packages { | ||
named("js") { | ||
scope.set("dhis2") | ||
readme.set(File("./README.md")) | ||
packageJson { | ||
"module" by "${project.name}.mjs" | ||
"main" by "" | ||
"exports" by { | ||
"import" by "./${project.name}.mjs" | ||
} | ||
"contributors" by Props.DEVELOPERS.map { developer -> | ||
"${developer.name} <${developer.email}>" | ||
} | ||
"description" by Props.DESCRIPTION | ||
"license" by Props.LICENSE_NAME | ||
"repository" by { | ||
"type" by Props.REPOSITORY_TYPE | ||
"url" by Props.REPOSITORY_URL | ||
} | ||
"publishConfig" by { | ||
"access" by "public" | ||
} | ||
} | ||
} | ||
} | ||
registries { | ||
npmjs { | ||
authToken.set(npmjsToken) | ||
} | ||
} | ||
} | ||
|
||
tasks.named("assembleJsPackage") { | ||
doLast { | ||
val file = file("${layout.buildDirectory.get()}/packages/js/package.json") | ||
val mainRegex = "\n \"main\": \"\"," | ||
val removedMain = file.readText().replace(mainRegex, "") | ||
file.writeText(removedMain) | ||
} | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.