Skip to content

Commit 43ea802

Browse files
yigittschuchortdev
authored andcommitted
update readme, set long name for the ksp module
1 parent de39e5f commit 43ea802

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,34 @@ However, if your project or any of its dependencies depend directly on compiler
113113

114114
Because the internal APIs of the Kotlin compiler often change between versions, we can only support one `kotlin-compiler-embeddable` version at a time.
115115

116+
## Kotlin Symbol Processing API Support
117+
[Kotlin Symbol Processing (KSP)](https://goo.gle/ksp) is a new annotation processing pipeline that builds on top of the
118+
plugin architecture of the Kotlin Compiler, instead of delegating to javac as `kapt` does.
119+
120+
**Note:** KSP is currently in active development and requires Kotlin 1.4 hence its support is kept separate from the
121+
main project until it becomes stable.
122+
123+
To test KSP processors, you need to add a dependency to the ksp module:
124+
125+
```Groovy
126+
dependencies {
127+
implementation 'com.github.tschuchortdev:kotlin-compile-testing-ksp:1.2.9'
128+
}
129+
```
130+
131+
This module adds a new function to the `KotlinCompilation` to specify KSP processors:
132+
133+
```Kotlin
134+
class MySymbolProcessor : SymbolProcessor {
135+
// implementation of the SymbolProcessor from the KSP API
136+
}
137+
138+
val result = KotlinCompilation().apply {
139+
sources = listOf(source)
140+
symbolProcessor(MySymbolProcessor::class.java)
141+
}.compile()
142+
```
143+
116144
## Projects that use Kotlin-Compile-Testing
117145

118146
- [square/moshi](https://github.com/square/moshi)

ksp/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
apply plugin: 'kotlin'
2-
// TODO remove group and version
2+
apply plugin: 'maven'
3+
apply plugin: 'com.vanniktech.maven.publish'
4+
35
group 'com.github.tschuchortdev'
4-
version '1.2.8'
6+
57
ext.ksp_version='1.4-M1-dev-experimental-20200610'
68

79
repositories {
@@ -27,4 +29,4 @@ compileKotlin {
2729
}
2830
compileTestKotlin {
2931
kotlinOptions.jvmTarget = "1.8"
30-
}
32+
}

ksp/src/main/kotlin/com/tschuchort/compiletesting/Ksp.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.ksp.processing.SymbolProcessor
99

1010
private const val KSP_PLUGIN_ID = "org.jetbrains.kotlin.ksp"
1111

12-
// TODO can we add support for instances?
1312
fun KotlinCompilation.symbolProcessor(
1413
vararg processors: Class<out SymbolProcessor>
1514
) {

ksp/src/test/kotlin/com/tschuchort/compiletesting/KspTestUtil.kt

Lines changed: 0 additions & 2 deletions
This file was deleted.

settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
rootProject.name = 'kotlin-compile-testing'
2-
include("ksp")
3-
2+
include(":kotlin-compile-testing-ksp")
3+
project(":kotlin-compile-testing-ksp").setProjectDir(new File("ksp"))

0 commit comments

Comments
 (0)