https://github.com/overpas/default-impl
A Kotlin Symbol Processing tool generating default interface implementation constructor functions
https://github.com/overpas/default-impl
kotlin kotlin-multiplatform ksp
Last synced: 2 days ago
JSON representation
A Kotlin Symbol Processing tool generating default interface implementation constructor functions
- Host: GitHub
- URL: https://github.com/overpas/default-impl
- Owner: overpas
- License: mit
- Created: 2023-08-24T11:41:15.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2026-05-13T20:01:46.000Z (29 days ago)
- Last Synced: 2026-05-13T22:06:12.608Z (29 days ago)
- Topics: kotlin, kotlin-multiplatform, ksp
- Language: Kotlin
- Homepage:
- Size: 242 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# default-impl
[](https://maven-badges.herokuapp.com/maven-central/io.github.overpas/default-impl-processor)
[](https://github.com/overpas/default-impl/actions/workflows/ci.yml)








A Kotlin Symbol Processing tool generating default interface implementation constructor functions
```kotlin
@DefaultImpl(MyInterfaceImpl::class)
interface MyInterface
internal object MyInterfaceImpl
val obj = MyInterface() // this will be generated with all constructor parameters
```
## Usage
#### In Kotlin Multiplatform projects
In your `build.gradle.kts`:
```gradle
plugins {
// ...
id("com.google.devtools.ksp")
}
kotlin {
// ...
sourceSets {
val commonMain by getting {
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") // optional: if you want to generate the code in commonMain
dependencies {
implementation("io.github.overpas:default-impl-annotations:0.0.2")
}
}
// ...
}
}
dependencies {
add("kspCommonMainMetadata", "io.github.overpas:default-impl-processor:0.0.2")
// other configurations (don't include any if you want to generate the code in commonMain):
// add("kspJvm", "io.github.overpas:default-impl-processor:0.0.2")
// add("kspAndroid", "io.github.overpas:default-impl-processor:0.0.2")
// add("kspIosArm64", "io.github.overpas:default-impl-processor:0.0.2")
// etc.
}
// optional: if you want to generate the code in commonMain
tasks.withType>().configureEach {
if (name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
}
}
```
#### In plain Kotlin projects
In your `build.gradle.kts`
```gradle
plugins {
// ...
id("com.google.devtools.ksp")
}
dependencies {
implementation("io.github.overpas:default-impl-annotations:0.0.2")
ksp("io.github.overpas:default-impl-processor:0.0.2")
}
```
## Troubleshooting
If you are using Detekt and `detektMetadataMain` fails with `Reason: Task ':detektMetadataMain' uses this output of task ':kspCommonMainKotlinMetadata' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
` you might consider adding:
```gradle
tasks.matching { it.name == "detektMetadataMain" }
.configureEach {
dependsOn(tasks.matching { it.name == "kspCommonMainKotlinMetadata" })
}
```