¶
Every Kotlin codebase has that file. Forty lines of id = id, name = name, email = email that nobody wanted to write and nobody wants to review. Kraft deletes it:
- fun User.toUserDto(): UserDto = UserDto(
- id = id,
- name = name,
- email = email,
- )
+ @MapConfig(source = User::class, target = UserDto::class)
+ object UserMapper
That's the whole mapper. Kraft is a KSP processor that generates type-safe extension functions between your data classes — plain, readable Kotlin you can inspect in build/generated. No reflection, no runtime library, nothing to ship.
What Kraft handles for you¶
-
Basic mapping
Same-name properties map automatically —
@MapConfig,@MapFrom, or@MapTo, whichever fits your layering. -
Nested objects & collections
Child mappers are auto-detected when types differ, and
List<T>/Set<T>map their elements along the way. -
Enums
@MapEnummatches entries by name and lets you pin the exceptions with custom entry pairs. -
Custom converters
@MapUsingfor one-off transformations,@KraftConverterfor converters discovered across the whole classpath. -
Reverse mapping
One
@MapReverseand the inverse mapper is generated too — renames, converters, and ignores included. -
AI-assisted workflows
A ready-made skill file teaches coding agents to write Kraft mappers correctly on the first try.
Install¶
Kraft is on Maven Central (com.blu3berry.kraft) — ensure mavenCentral() is in your repositories { } block, then replace <version> with the release shown in the badge above. The Gradle plugin wires everything (dependencies, generated sources, task ordering) on Kotlin Multiplatform, JVM, and Android modules:
// build.gradle.kts
plugins {
kotlin("multiplatform") // or kotlin("jvm") / kotlin("android")
id("com.google.devtools.ksp") version "2.3.3"
id("com.blu3berry.kraft") version "<version>"
}
See Getting Started for manual wiring, requirements, KSP version matching, and legacy-project compatibility.
Where next¶
- Getting Started — installation and your first mapper
- User Guide — every feature, with examples
- Architecture — internals and the plugin SPI
- Contributing — your first contribution, step by step