https://github.com/virelion/buildata
Kotlin multiplatform builder generator.
https://github.com/virelion/buildata
builder codegen kotlin kotlin-multiplatform
Last synced: 10 months ago
JSON representation
Kotlin multiplatform builder generator.
- Host: GitHub
- URL: https://github.com/virelion/buildata
- Owner: Virelion
- License: apache-2.0
- Created: 2021-01-16T20:03:50.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-09-27T12:47:53.000Z (10 months ago)
- Last Synced: 2025-09-27T14:41:39.327Z (10 months ago)
- Topics: builder, codegen, kotlin, kotlin-multiplatform
- Language: Kotlin
- Homepage:
- Size: 536 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README











Kotlin multiplatform code-generator for typed tree data class structures.
# [Builder generator](docs/data-tree-building.md)
Generate builders for your immutable data classes.
Annotate class:
```kotlin
@Buildable
data class Root(
//...
)
```
and use builders:
```kotlin
Root::class.build {
branch {
leaf = "My value"
}
}
```
See more in [data-tree-building.md](docs/data-tree-building.md)
# [Path reflection](docs/path-reflection.md)
Generate builders for your immutable data classes.
Annotate class:
```kotlin
@PathReflection
data class Root(
//...
)
```
and automatically gather information about the path to the value:
```kotlin
root.withPath().branch.leaf.path().jsonPath // will return "$.branch.leaf"
```
See more in [path-reflection.md](docs/path-reflection.md)
# [Dynamic access](docs/dynamic-access.md)
All `@Buildable` classes can be dynamically accessed.
Annotate class:
```kotlin
@Buildable
data class Item(
val value: String,
val list: List>
// ...
)
```
and access data dynamically with generated accessors:
```kotlin
item.dynamicAccessor["value"] // returns item.value
item.dynamicAccessor["$.list[2]['element']"] // returns item.list[2]["element"]
```
See more in [dynamic-access.md](docs/dynamic-access.md)
# How to set up?
0. Have open source repositories connected to project:
```kotlin
buildscript {
repositories {
gradlePluginPortal()
// ...
}
}
repositories {
mavenCentral()
// ...
}
```
1. Add buildata plugin to your build
```kotlin
plugins {
kotlin("multiplatform") version "2.2.20"
kotlin("jvm") version "2.2.20" // alternatively
}
```
2. Add buildata runtime to your dependencies
For JVM Kotlin projects
```kotlin
plugins {
kotlin("jvm")
id("com.google.devtools.ksp") version "2.2.20-2.0.3"
}
dependencies {
add("ksp", project(":buildata-ksp-plugin"))
implementation("io.github.virelion.buildata:buildata-runtime:")
}
```
For multiplatform:
```kotlin
kotlin {
// ...
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.virelion.buildata:buildata-runtime:")
}
}
// ...
}
}
dependencies {
add("kspCommonMainMetadata", project("io.github.virelion.buildata:buildata-ksp-plugin:"))
}
afterEvaluate {
tasks.withType>().all {
if (name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
}
}
}
```