Skip to content

Virelion/buildata

Repository files navigation

logo

badge badge badge badge badge badge badge

verification version last-commit

Kotlin multiplatform code-generator for typed tree data class structures.

Generate builders for your immutable data classes. Annotate class:

@Buildable
data class Root(
    //...
)

and use builders:

Root::class.build {
    branch {
        leaf = "My value"
    }
}

See more in data-tree-building.md

Generate builders for your immutable data classes.

Annotate class:

@PathReflection
data class Root(
    //...
)

and automatically gather information about the path to the value:

root.withPath().branch.leaf.path().jsonPath // will return "$.branch.leaf"

See more in path-reflection.md

All @Buildable classes can be dynamically accessed.

Annotate class:

@Buildable
data class Item(
    val value: String,
    val list: List<Map<String,String>>
    // ...
)

and access data dynamically with generated accessors:

item.dynamicAccessor["value"] // returns item.value
item.dynamicAccessor["$.list[2]['element']"] // returns item.list[2]["element"]

See more in dynamic-access.md

How to set up?

  1. Have open source repositories connected to project:
buildscript {
    repositories {
        gradlePluginPortal()
        // ...
    }
}

repositories {
    mavenCentral()
    // ...
}
  1. Add buildata plugin to your build
plugins {
    kotlin("multiplatform") version "2.2.20"
    kotlin("jvm") version "2.2.20" // alternatively
}
  1. Add buildata runtime to your dependencies

For JVM Kotlin projects

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:<LIBRARY_VERSION>")
}

For multiplatform:

kotlin {
    // ...
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("io.github.virelion.buildata:buildata-runtime:<LIBRARY_VERSION>")
            }
        }

        // ...
    }
}

dependencies {
    add("kspCommonMainMetadata", project("io.github.virelion.buildata:buildata-ksp-plugin:<LIBRARY_VERSION>"))
}

afterEvaluate {
    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>().all {
        if (name != "kspCommonMainKotlinMetadata") {
            dependsOn("kspCommonMainKotlinMetadata")
        }
    }
}

About

Kotlin multiplatform builder generator.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors 3

  •  
  •  
  •