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

Cleanup workarounds for KSP that aren't needed anymore #192

Merged
merged 1 commit into from
Jul 7, 2023
Merged
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
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