Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

- [ ] All tests pass (`./gradlew allTests`)
- [ ] Lint passes (`./gradlew ktlintCheck`)
- [ ] API compatibility verified (`./gradlew apiCheck`)
- [ ] API compatibility verified (`./gradlew checkKotlinAbi`)
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: ./gradlew :deci:ktlintCheck

- name: API compatibility check
run: ./gradlew :deci:apiCheck
run: ./gradlew :deci:checkKotlinAbi

- name: Run JVM tests
run: ./gradlew :deci:jvmTest
Expand Down
34 changes: 33 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# Changelog

## [Unreleased]
## [0.3.0] - 2026-06-09

### Changed

- **The `/` and `%` operators are now fixed to `DeciContext.DEFAULT`.** Behaviour
is unchanged for any code that never reassigned the (now-removed) global
`divisionPolicy`: bare division still yields 20 fractional digits with
`HALF_UP` rounding, and `%` (which is computed via `/`) is likewise unaffected.

- **Migrated to the Kotlin Gradle plugin's built-in ABI validation — no public
API or runtime changes.** Dropped the deprecated standalone
`org.jetbrains.kotlinx:binary-compatibility-validator` plugin in favour of the
Kotlin Gradle plugin's `abiValidation { }` DSL. The `apiDump` / `apiCheck`
tasks are replaced by `updateKotlinAbi` / `checkKotlinAbi`, and the reference
dump now lives at `deci/api/jvm/deci.api` (JVM) plus `deci/api/deci.klib.api`
(Kotlin/Native, JS, and Wasm). Removed the `binary-compatibility-validator`
version and `bcv-gradle-plugin` version-catalog entries.

### Removed

- **Deprecated division-policy configuration removed (breaking).** Deleted
`DeciConfiguration.divisionPolicy`, `DeciConfiguration.resetDivisionPolicy()`,
and the `DeciDivisionPolicy` class. The `/` operator no longer reads a global
mutable policy; it always divides with `DeciContext.DEFAULT` (20 fractional
digits, `HALF_UP`) — identical to the previous out-of-the-box default. To
customise division scale or rounding, pass an explicit context per call:
`a.divide(b, DeciContext.CURRENCY_USD)` or
`a.divide(b, scale = 4, roundingMode = RoundingMode.HALF_EVEN)`.
`DeciConfiguration.logSink` / `disableLogging()` are unaffected.

- **`Iterable<Deci>.averageDeci()` removed (breaking).** Use
`Iterable<Deci>.mean()` from `org.kimplify.deci.statistics` instead — a drop-in
replacement with the same signature and semantics: `values.mean(context)`.

## [0.2.2] - 2026-06-05

Expand Down
10 changes: 5 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ val expected = 0.10.toDecimal()
./gradlew publishToMavenLocal

# Generate API binary-compatibility dump
./gradlew apiDump
./gradlew updateKotlinAbi

# Check for binary-compatibility regressions
./gradlew apiCheck
./gradlew checkKotlinAbi
```

---

## API Stability

- This library uses [kotlin-binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator).
- Run `./gradlew apiDump` after any public API change and commit the updated `.api` file.
- `./gradlew apiCheck` runs in CI and will fail the build on unintentional API changes.
- This library uses the Kotlin Gradle plugin's [built-in ABI validation](https://kotlinlang.org/docs/whatsnew2120.html#binary-compatibility-validation-in-the-kotlin-gradle-plugin) (`abiValidation`).
- Run `./gradlew updateKotlinAbi` after any public API change and commit the updated dump files under `deci/api/` (`jvm/deci.api` for JVM, `deci.klib.api` for the Kotlin/Native, JS, and Wasm targets).
- `./gradlew checkKotlinAbi` runs in CI and will fail the build on unintentional API changes.
- Mark experimental APIs with `@ExperimentalDeciApi` and require opt-in.

---
Expand Down
12 changes: 7 additions & 5 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,19 @@ Values serialize as JSON **strings** to preserve trailing zeros and avoid lossy

## Configuration

Division scale and rounding are chosen per call via `DeciContext` — there is no global
mutable division policy. The `/` operator uses `DeciContext.DEFAULT` (20 fractional
digits, `HALF_UP`); pass an explicit context or `scale`/`roundingMode` for anything else:

```kotlin
DeciConfiguration.divisionPolicy = DeciDivisionPolicy(
fractionalDigits = 6,
roundingMode = RoundingMode.HALF_UP
)
Deci("10") / Deci("3") // DeciContext.DEFAULT
Deci("10").divide(Deci("3"), DeciContext.CURRENCY_USD) // 2 digits, HALF_UP
Deci("10").divide(Deci("3"), scale = 4, roundingMode = RoundingMode.HALF_EVEN)

DeciConfiguration.logSink = DeciLogSink { tag, message ->
println("[$tag] $message")
}

DeciConfiguration.resetDivisionPolicy()
DeciConfiguration.disableLogging()
```

Expand Down
1 change: 0 additions & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ dependencies {
implementation(libs.kotlin.gradle.plugin)
implementation(libs.android.gradle.plugin)
implementation(libs.ktlint.gradle.plugin)
implementation(libs.bcv.gradle.plugin)
}
8 changes: 6 additions & 2 deletions build-logic/src/main/kotlin/deci.kmp.library.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
@file:OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class)
@file:OptIn(
org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class,
org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation::class,
)

plugins {
id("org.jetbrains.kotlin.multiplatform")
id("com.android.kotlin.multiplatform.library")
id("org.jlleitschuh.gradle.ktlint")
id("org.jetbrains.kotlinx.binary-compatibility-validator")
}

kotlin {
jvmToolchain(21)

abiValidation {}

jvm()
js { browser() }
wasmJs { browser() }
Expand Down
Loading
Loading