Michal Klimczak
06/15/2022, 1:07 PMiosMain
source set? I'm using ksp 1.6.21-1.0.5 and even if I do
configurations
.filter { it.name.startsWith("ksp") }
.forEach {
add(it.name, "com.example...")
}
all I get is android source sets. If I try to add to ios configs, it doesn't complain but no code is generated. (the annotated files are in commonMain
btw).
An example of os library which generates code for different source sets would be awesome.Oliver.O
06/15/2022, 9:57 PMksp...
task for your iosMain
source set.
If you want to experiment and build a KSP version with source set configuration support, you could try the following:
• Clone this repository: https://github.com/OliverO2/ksp.git
• Check out the branch multiplatform-fixes-1.0.5-kotlin-1.6.21
• In the KSP project's root directory, run ./gradlew publishAllPublicationsToTestRepository
• In your project's root directory, add these lines to gradle.properties
, replacing `<YOUR_KSP_PROJECT_DIRECTORY>`:
ksp.multiplatform.enabled=true
kotlinVersion=1.6.21
kspVersion=2.0.255-SNAPSHOT
testRepo=<YOUR_KSP_PROJECT_DIRECTORY>/build/repos/test
• Make settings.gradle.kts
contain a pluginManagement
block like this:
pluginManagement {
val kotlinVersion: String by settings
val kspVersion: String by settings
val testRepo: String by settings
plugins {
id("com.google.devtools.ksp") version kspVersion apply false
kotlin("multiplatform") version kotlinVersion apply false
}
repositories {
maven(testRepo)
gradlePluginPortal()
}
}
• Make build.gradle.kts
contain at least like this:
plugins {
kotlin("multiplatform") apply false
}
val testRepo: String by project
allprojects {
repositories {
maven(testRepo)
mavenCentral()
}
}
• Configure source sets with the ksp
extension as explained here: https://github.com/google/ksp/pull/1021.
Does that help?Michal Klimczak
06/16/2022, 7:45 AMOliver.O
06/16/2022, 11:21 AMiosMain
source set is not there yet may be that it is lazily configured after the KSP plugin has been initialized. (You know Gradle's callback hell named configuration avoidance?) My PR enables lazy configuration for source sets, and that makes a difference with some setups.efemoney
06/16/2022, 11:30 AMconfigurations.matching { … }.configureEach { … }
efemoney
06/16/2022, 11:31 AMforEach
(probably) isn’t even Gradle API 🙂Michal Klimczak
06/16/2022, 12:03 PM