Skip to content

Commit

Permalink
Cleanup workarounds for KSP that aren't needed anymore (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
eygraber authored Jul 7, 2023
1 parent 2b67596 commit 616e562
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions conventions-plugin/src/main/kotlin/ksp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,14 @@ import com.eygraber.conventions.capitalize
import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.kotlin.dsl.dependencies
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.kpm.external.ExternalVariantApi
import org.jetbrains.kotlin.gradle.kpm.external.project
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

interface KspDependencies {
fun ksp(dependencyNotation: Any)
}

fun KotlinProjectExtension.configureKspSourceSets() {
check(this !is KotlinMultiplatformExtension) {
"""
|configureKspSourceSets isn't meant to be used with KMP.
|Please use one of the functions meant for use with KMP:
| KotlinTarget.kspDependencies
| KotlinMultiplatformExtension.kspDependenciesForAllTargets
| KotlinMultiplatformExtension.commonMainKspDependencies
""".trimMargin()
}

sourceSets.configureEach {
kotlin.srcDir("build/generated/ksp/$name/kotlin")
kotlin.srcDir("build/generated/ksp/$name/java")
resources.srcDir("build/generated/ksp/$name/resources")
}
}

fun KotlinTarget.kspDependencies(block: KspDependencies.() -> Unit) {
val configurationName = "ksp${targetName.capitalize()}"
project.dependencies {
Expand All @@ -39,13 +19,6 @@ fun KotlinTarget.kspDependencies(block: KspDependencies.() -> Unit) {
}
}.block()
}

compilations.configureEach {
kotlinSourceSets.forEach { sourceSet ->
sourceSet.kotlin.srcDir("build/generated/ksp/$targetName/${sourceSet.name}/kotlin")
sourceSet.resources.srcDir("build/generated/ksp/$targetName/${sourceSet.name}/resources")
}
}
}

fun KotlinMultiplatformExtension.kspDependenciesForAllTargets(block: KspDependencies.() -> Unit) {
Expand All @@ -66,16 +39,6 @@ fun KotlinMultiplatformExtension.commonMainKspDependencies(block: KspDependencie
}.block()
}

sourceSets.named("commonMain").configure {
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
}

project.tasks.withType(KotlinCompilationTask::class.java).configureEach {
if(name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
}
}

project.plugins.withId("io.gitlab.arturbosch.detekt") {
project.tasks.withType(Detekt::class.java).configureEach {
if(name != "detekt") {
Expand Down

0 comments on commit 616e562

Please sign in to comment.