Skip to content

Commit

Permalink
Simplify configuration name resolution (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers authored Sep 3, 2023
1 parent 589986a commit 9531017
Showing 1 changed file with 4 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ package dev.zacsweers.redacted.gradle

import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerPluginSupportPlugin
import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet

public class RedactedGradleSubplugin : KotlinCompilerPluginSupportPlugin {

Expand Down Expand Up @@ -51,31 +49,10 @@ public class RedactedGradleSubplugin : KotlinCompilerPluginSupportPlugin {
// Default annotation is used, so add it as a dependency
// Note only multiplatform, jvm/android, and js are supported. Anyone else is on their own.
if (annotation.get() == DEFAULT_ANNOTATION) {
when {
project.plugins.hasPlugin("org.jetbrains.kotlin.multiplatform") -> {
val sourceSets =
project.extensions.getByType(KotlinMultiplatformExtension::class.java).sourceSets
val sourceSet = (sourceSets.getByName("commonMain") as DefaultKotlinSourceSet)
project.configurations
.getByName(sourceSet.apiConfigurationName)
.dependencies
.add(
project.dependencies.create(
"dev.zacsweers.redacted:redacted-compiler-plugin-annotations:$VERSION"
)
)
}
else -> {
project.configurations
.getByName("implementation")
.dependencies
.add(
project.dependencies.create(
"dev.zacsweers.redacted:redacted-compiler-plugin-annotations:$VERSION"
)
)
}
}
project.dependencies.add(
kotlinCompilation.implementationConfigurationName,
"dev.zacsweers.redacted:redacted-compiler-plugin-annotations:$VERSION"
)
}

val enabled = extension.enabled.get()
Expand Down

0 comments on commit 9531017

Please sign in to comment.