Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove KAPT support #1848

Merged
merged 4 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
kotlin-test-mode: [ 'REFLECT', 'KSP', 'KAPT' ]
kotlin-test-mode: [ 'REFLECT', 'KSP' ]

steps:
- name: Checkout
Expand Down
20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ Note that the reflection adapter transitively depends on the `kotlin-reflect` li

#### Codegen

Moshi’s Kotlin codegen support can be used as an annotation processor (via [kapt][kapt]) or Kotlin SymbolProcessor ([KSP][ksp]).
Moshi’s Kotlin codegen support can be used as a Kotlin SymbolProcessor ([KSP][ksp]).
It generates a small and fast adapter for each of your Kotlin classes at compile-time. Enable it by annotating
each class that you want to encode as JSON:

Expand Down Expand Up @@ -1109,23 +1109,6 @@ dependencies {
```
</details>

<details>
<summary>Kapt</summary>

```xml
<dependency>
<groupId>com.squareup.moshi</groupId>
<artifactId>moshi-kotlin-codegen</artifactId>
<version>1.15.1</version>
<scope>provided</scope>
</dependency>
```

```kotlin
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.15.1")
```
</details>

#### Limitations

If your Kotlin class has a superclass, it must also be a Kotlin class. Neither reflection or codegen
Expand Down Expand Up @@ -1190,5 +1173,4 @@ License
[okhttp]: https://github.com/square/okhttp/
[gson]: https://github.com/google/gson/
[javadoc]: https://square.github.io/moshi/1.x/moshi/
[kapt]: https://kotlinlang.org/docs/reference/kapt.html
[ksp]: https://github.com/google/ksp
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ plugins {
alias(libs.plugins.dokka) apply false
alias(libs.plugins.spotless)
alias(libs.plugins.japicmp) apply false
alias(libs.plugins.ksp) apply false
}

allprojects {
Expand Down
4 changes: 2 additions & 2 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm")
kotlin("kapt")
alias(libs.plugins.ksp)
}

dependencies {
kapt(project(":moshi-kotlin-codegen"))
ksp(project(":moshi-kotlin-codegen"))
compileOnly(libs.jsr305)
implementation(project(":moshi"))
implementation(project(":moshi-adapters"))
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# Memory for Dokka https://github.com/Kotlin/dokka/issues/1405
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8

kapt.include.compile.classpath=false
48 changes: 0 additions & 48 deletions moshi-kotlin-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer
import com.vanniktech.maven.publish.JavadocJar.None
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.MavenPublishBaseExtension
Expand All @@ -8,7 +7,6 @@ plugins {
kotlin("jvm")
id("com.google.devtools.ksp")
id("com.vanniktech.maven.publish.base")
alias(libs.plugins.mavenShadow)
}

tasks.withType<KotlinCompile>().configureEach {
Expand All @@ -26,35 +24,9 @@ tasks.compileTestKotlin {
}
}

// --add-opens for kapt to work. KGP covers this for us but local JVMs in tests do not
tasks.withType<Test>().configureEach {
jvmArgs(
"--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
)
}

val shade: Configuration = configurations.maybeCreate("compileShaded")
configurations.getByName("compileOnly").extendsFrom(shade)
dependencies {
implementation(project(":moshi"))
shade(libs.kotlinxMetadata) {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
}
api(libs.kotlinpoet)
shade(libs.kotlinpoet.metadata) {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "com.squareup", module = "kotlinpoet")
exclude(group = "com.google.guava")
}
implementation(libs.kotlinpoet.ksp)
implementation(libs.guava)
implementation(libs.asm)
Expand Down Expand Up @@ -83,26 +55,6 @@ dependencies {
testImplementation(libs.kotlinCompileTesting)
}

val shadowJar =
tasks.shadowJar.apply {
configure {
archiveClassifier.set("")
configurations = listOf(shade)
relocate("com.squareup.kotlinpoet.metadata", "com.squareup.moshi.kotlinpoet.metadata")
relocate(
"com.squareup.kotlinpoet.classinspector",
"com.squareup.moshi.kotlinpoet.classinspector",
)
relocate("kotlinx.metadata", "com.squareup.moshi.kotlinx.metadata")
transformers.add(ServiceFileTransformer())
}
}

artifacts {
runtimeOnly(shadowJar)
archives(shadowJar)
}

configure<MavenPublishBaseExtension> {
configure(KotlinJvm(javadocJar = None()))
}

This file was deleted.

Loading