-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
175 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,52 @@ | ||
# toothpick-compiler-ksp | ||
# KSP Processor for Toothpick ![Release](https://jitpack.io/v/fr.outadoc/toothpick-compiler-ksp.svg) | ||
|
||
## Background | ||
|
||
[Toothpick](https://github.com/stephanenicolas/toothpick) is a Dependency Injection library for Java & Kotlin. | ||
|
||
An important part of Toothpick is its ability to generate code at compile-time to avoid doing expensive reflection at | ||
runtime. This is handled by an *annotation processor*, which uses Java's `apt` and Kotlin's `kapt` APIs. | ||
|
||
Recently, Google has released an alternative, modern annotation processor, built for Kotlin and compatible with Java | ||
projects: KSP (Kotlin Symbol Processor). This API is much faster than `kapt` on Kotlin projects. | ||
|
||
## Goals | ||
|
||
This projects aims to reimplement Toothpick's annotation processor with Kotlin-based technologies. It now uses KSP for | ||
better build performance, and generates Kotlin code for improved type safety. | ||
|
||
> **Important note:** This processor is mostly a drop-in replacement for the official `kapt` processor, but compatibility was *not* a main goal. You might need to make small changes to your code in order to build using this module. | ||
> | ||
> This is in part because of fundamental differences in the way KSP models Kotlin code compared to `kapt`, and in part because of the differences in generated Kotlin code vs. Java code (no `package` visibility modifier, for example.) | ||
## Setup | ||
|
||
```kotlin | ||
plugins { | ||
// Remove this if you don't have any kapt(...) processors left in your dependencies: | ||
// kotlin("kapt") version "..." | ||
|
||
// Use the version that matches your Kotlin version! | ||
id("com.google.devtools.ksp") version "1.6.10-1.0.2" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url = uri("https://jitpack.io") } | ||
} | ||
|
||
dependencies { | ||
// Remove this: | ||
// kapt("com.github.stephanenicolas.toothpick:toothpick-compiler:...") | ||
|
||
ksp("fr.outadoc.toothpick-compiler-ksp:toothpick-compiler-ksp:0.1") | ||
} | ||
|
||
ksp { | ||
// If you need to, specify some extra options. | ||
// See ToothpickOptions.kt for documentation. | ||
arg("option1", "value1") | ||
arg("option2", "value2") | ||
// ... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.