Skip to content

Commit

Permalink
Fixes issues with KSP and generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzo committed Nov 26, 2024
1 parent 9261cb2 commit 96a1223
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions demo-project/kmp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
plugins {
alias(libs.plugins.android.lib)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.ksp)
}

afterEvaluate {
Expand All @@ -30,5 +31,7 @@ kotlin {
}

dependencies {
ksp(libs.moshi.codegen)
commonMainImplementation(libs.moshi.kotlin)
commonTestImplementation(libs.kotlin.test)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.kmp

import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class MoshiObjAndroid(
val a: String,
val b: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.kmp

import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class MoshiObjJVM(
val a: String,
val b: String,
)
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ android-minSDK = "21"
android-compileSDK = "35"
androidx-lifecycle = "2.8.7"
androidx-navigation = "2.8.4"
moshi = "1.15.1"

[libraries]
androidx-core = "androidx.core:core-ktx:1.15.0"
Expand All @@ -19,6 +20,8 @@ androidx-test-junit = "androidx.test.ext:junit:1.2.1"
androidx-test-espresso = "androidx.test.espresso:espresso-core:3.6.1"
google-material = "com.google.android.material:material:1.12.0"
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" }
moshi-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi" }
robolectric = "org.robolectric:robolectric:4.14.1"

[plugins]
Expand All @@ -29,6 +32,7 @@ android-baseline = { id = "androidx.baselineprofile", version = "1.3.3" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-ksp = { id = "com.google.devtools.ksp", version = "2.0.21-1.0.25" }
kotlin-samReceiver = { id = "org.jetbrains.kotlin.plugin.sam.with.receiver", version.ref = "kotlin" }
gradle-pluginPublish = { id = "com.gradle.plugin-publish", version = "1.3.0" }
publicationsReport = { id = "io.github.gmazzo.publications.report", version = "1.2.8" }
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ abstract class AndroidTestCoverageAggregationPlugin : Plugin<Project> {
}
allVariantsSourcesForCoverageReport.configure {
main.allKotlinSourceSets.forAll {
from(it.kotlin.srcDirs)
from(it.kotlin)
}
}
allVariantsClassesForCoverageReport.configure {
Expand Down

0 comments on commit 96a1223

Please sign in to comment.