Skip to content

Commit

Permalink
Update README, enhance build settings, modify serialization version
Browse files Browse the repository at this point in the history
Updated the README file to clarify the 'require' block usage. Improved build.gradle.kts by adding more configurations and updating Kotlin plugin and serialization library versions. The serialization library version is now managed from gradle.properties. Upgraded gradle version in gradle-wrapper.properties file.
  • Loading branch information
L-Briand committed Dec 7, 2023
1 parent f2b9e98 commit c1cdbab
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 16 deletions.
13 changes: 7 additions & 6 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ It adds a depth level to your serialization with `left` or `right` value.

```
Left("value") <=> { "left": "value" }
Right("value") <=> { "right": "value" }
Right(12345) <=> { "right": 12345 }
```

You will get a deserialization exception if both `left` and `right` are together.
Expand Down Expand Up @@ -244,9 +244,10 @@ There are no operators like `either.withLeft { }` or `option.withValue { }` as i
handling if the type is wrong. Instead, the lib provides the inverted thinking, handles the error case and
continues.

In a `require` block you either need to return or throw an exception.
You cannot let the code go at the end of the block. Use destructuring syntax to handle `Either` / `Option` values
directly.
In a `require` block you are requiring to **return** or **throw** an exception.
You cannot let the code go at the end of the block.

You can use destructuring syntax to handle `Either` / `Option` values directly.

#### Either

Expand All @@ -257,8 +258,8 @@ val _: String = either.requireLeft { value: Right<Int> -> error("Will not fail")
val _: Int = either.requireRight { value: Left<String> -> error("Will fail") }

fun test() {
val _: String = either.requireLeft { (value: Int) -> return }
val _: Int = either.requireRight { (value: String) -> return }
val _: String = either.requireLeft { (value: Int) -> return@test }
val _: Int = either.requireRight { (value: String) -> return@test }
}
```

Expand Down
55 changes: 46 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform") version "1.9.0"
kotlin("plugin.serialization") version "1.9.0"
kotlin("multiplatform") version "1.9.21"
kotlin("plugin.serialization") version "1.9.21"
id("maven-publish")
id("signing")
}
Expand All @@ -24,28 +26,63 @@ repositories {

kotlin {
jvm {
compilations.getByName("main") {
kotlinOptions { jvmTarget = "1.8" }
}
jvmToolchain(8)
withJava()
withSourcesJar(true)
testRuns.named("test") {
executionTask.configure { useJUnitPlatform() }
}
}

js("js") {
// web

js {
browser()
nodejs()
}

macosArm64("macosArm64")
macosX64("macosX64")
linuxArm64("linuxArm64")
linuxX64("linuxX64")
mingwX64("mingwX64")
@OptIn(ExperimentalWasmDsl::class)
wasmJs { d8() }
// wasmWasi { nodejs() }

// https://kotlinlang.org/docs/native-target-support.html

// Tier1

macosX64()
macosArm64()
iosSimulatorArm64()
iosX64()

// Tier2

linuxX64()
linuxArm64()
watchosSimulatorArm64()
watchosX64()
watchosArm32()
watchosArm64()
tvosSimulatorArm64()
tvosX64()
tvosArm64()
iosArm64()

// Tier3
androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()
mingwX64()
watchosDeviceArm64()

sourceSets {
getByName("commonMain") {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
val serialization = findProperty("version.serialization") !!
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization")
}
}
getByName("commonTest") {
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kotlin.js.compiler=ir
# Global information
group=net.orandja.kt
version=1.1.1
# Dependencies
version.serialization=1.6.2
# Artifact related
POM_NAME=KTM
POM_DESCRIPTION=Either and Option implementation in Kotlin Multiplatform
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit c1cdbab

Please sign in to comment.