Skip to content

GitHub Release

Kraft

Compile-time mapper generation for Kotlin Multiplatform.

Kraft is a KSP-based annotation processor that generates type-safe extension functions to map between data classes. No reflection, no runtime overhead — just clean, generated Kotlin code.

Features

  • Annotation-driven@MapConfig, @MapFrom, or @MapTo to declare mappings
  • Property matching — same-name properties mapped automatically
  • Field renaming@MapField or @FieldMapping for cross-name mapping
  • Nested objects — auto-detected or explicit @MapNested, with implicit child mapper generation
  • CollectionsList<T> and Set<T> with nested element mapping
  • Enum mapping@MapEnum with auto-matching and custom entry pairs
  • Custom converters@MapUsing for property-source or whole-source transformations
  • Reverse mapping@MapReverse generates the inverse mapper automatically
  • Ignore rules@MapIgnore and @MapIgnoreField with directional control
  • Plugin SPI — implement MapperGeneratorProvider to plug in your own code generator
  • Kotlin Multiplatform — annotations work on JVM, iOS, JS, and WasmJs

Quick Start

// build.gradle.kts
plugins {
    id("com.google.devtools.ksp") version "2.3.3"
}

dependencies {
    implementation("com.blu3berry.kraft:kraft-annotations:<version>")
    ksp("com.blu3berry.kraft:kraft-ksp:<version>")
}
data class User(val id: Int, val name: String, val email: String)
data class UserDto(val id: Int, val name: String, val email: String)

@MapConfig(source = User::class, target = UserDto::class)
object UserMapper

// Generated: fun User.toUserDto(): UserDto

Documentation