Migrate from KAPT to KSP

This commit is contained in:
tzugen 2023-07-31 14:46:52 +02:00
parent f99fb1c92a
commit ddf8ce7029
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
7 changed files with 39 additions and 16 deletions

View File

@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: 'gradle/versions.gradle'
@ -10,6 +12,7 @@ buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
@ -26,21 +29,29 @@ allprojects {
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
}
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
// Set Kotlin JVM target to the same for all subprojects
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "17"
}
}
tasks.withType(JavaCompile).tap {
configureEach {
options.compilerArgs.add("-Xlint:deprecation")
}
}
}
wrapper {

View File

@ -1,11 +1,14 @@
plugins {
alias libs.plugins.ksp
}
apply from: bootstrap.androidModule
apply plugin: 'kotlin-kapt'
dependencies {
implementation libs.core
implementation libs.roomRuntime
implementation libs.roomKtx
kapt libs.room
ksp libs.room
}
android {

View File

@ -1,3 +1,7 @@
plugins {
alias libs.plugins.ksp
}
apply from: bootstrap.kotlinModule
dependencies {

View File

@ -17,6 +17,7 @@ constraintLayout = "2.1.4"
multidex = "2.0.1"
room = "2.5.2"
kotlin = "1.8.22"
ksp = "1.8.22-1.0.11"
kotlinxCoroutines = "1.7.3"
viewModelKtx = "2.6.1"
swipeRefresh = "1.1.0"
@ -100,3 +101,6 @@ kluentAndroid = { module = "org.amshove.kluent:kluent-android", versio
mockWebServer = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp" }
apacheCodecs = { module = "commons-codec:commons-codec", version.ref = "apacheCodecs" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
[plugins]
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

View File

@ -4,7 +4,7 @@
apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.android'
apply from: "${project.rootDir}/gradle_scripts/code_quality.gradle"
apply plugin: 'org.jetbrains.kotlin.kapt'
apply plugin: 'com.google.devtools.ksp'
android {
compileSdkVersion versions.compileSdk

View File

@ -2,7 +2,7 @@
* This module provides a base for for pure kotlin modules
*/
apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.kotlin.kapt'
apply plugin: 'com.google.devtools.ksp'
apply from: "${project.rootDir}/gradle_scripts/code_quality.gradle"
sourceSets {
@ -12,7 +12,6 @@ sourceSets {
test.resources.srcDirs += "${projectDir}/src/integrationTest/resources"
}
dependencies {
api libs.kotlinStdlib

View File

@ -1,6 +1,9 @@
plugins {
alias libs.plugins.ksp
}
apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android'
apply plugin: 'org.jetbrains.kotlin.kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply from: "../gradle_scripts/code_quality.gradle"
@ -64,20 +67,20 @@ android {
targetCompatibility JavaVersion.VERSION_17
}
kapt {
arguments {
arg("room.schemaLocation", "$rootDir/ultrasonic/schemas".toString())
}
ksp {
arg("room.schemaLocation", "$rootDir/ultrasonic/schemas")
}
lint {
baseline = file("lint-baseline.xml")
abortOnError true
warningsAsErrors true
disable 'IconMissingDensityFolder', 'VectorPath'
ignore 'MissingTranslation', 'UnusedQuantity', 'MissingQuantity'
warning 'ImpliedQuantity'
disable 'IconMissingDensityFolder', 'VectorPath'
disable 'MissingTranslation', 'UnusedQuantity', 'MissingQuantity'
disable 'ObsoleteLintCustomCheck'
// We manage dependencies on Gitlab with RenovateBot
disable 'GradleDependency'
textReport true
checkDependencies true
}
@ -85,7 +88,7 @@ android {
}
tasks.withType(Test) {
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
@ -129,7 +132,7 @@ dependencies {
implementation libs.rxAndroid
implementation libs.multiType
kapt libs.room
ksp libs.room
testImplementation libs.kotlinReflect
testImplementation libs.junit
@ -141,6 +144,5 @@ dependencies {
testImplementation libs.robolectric
implementation libs.timber
}