Skip to content

Commit

Permalink
Fix 270 (#278)
Browse files Browse the repository at this point in the history
* Reduce usages of Android classes

* Remove unused import
  • Loading branch information
BraisGabin authored Nov 22, 2024
1 parent 89b37a8 commit 34377e7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
1 change: 0 additions & 1 deletion gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.vanniktech.maven.publish.SonatypeHost.Companion.S01
import org.jetbrains.kotlin.gradle.internal.ensureParentDirsCreated
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.kotlin.jvm)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package schwarz.it.lightsaber.gradle

import com.android.build.gradle.BaseExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.provider.Property
Expand Down Expand Up @@ -56,7 +55,7 @@ private fun Project.apply() {
}

private fun Project.androidPluginApplied(): Boolean {
return extensions.findByType(BaseExtension::class.java) != null
return extensions.findByName("android") != null
}

internal fun Project.registerTask(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ fun Project.applyAndroidAnnotationProcessor(extension: LightsaberExtension) {
androidComponents.onVariants { variant ->
withDaggerCompiler { processor ->
val lightsaberVariantCheck = when (processor) {
Processor.AnnotationProcessor -> registerAnnotationProcessorTask(extension, variant)
Processor.Kapt -> registerKaptTask(extension, variant)
Processor.Ksp -> registerKspTask(extension, variant)
Processor.AnnotationProcessor -> registerAnnotationProcessorTask(extension, variant.name)
Processor.Kapt -> registerKaptTask(extension, variant.name)
Processor.Ksp -> registerKspTask(extension, variant.name)
}

lightsaberVariantCheck.configure {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package schwarz.it.lightsaber.gradle.processors

import com.android.build.api.variant.Variant
import org.gradle.api.Project
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.compile.JavaCompile
Expand All @@ -13,9 +12,9 @@ import schwarz.it.lightsaber.gradle.registerTask

internal fun Project.registerAnnotationProcessorTask(
extension: LightsaberExtension,
variant: Variant? = null,
variant: String? = null,
): TaskProvider<LightsaberTask> {
val variantName = variant?.name?.capitalized()
val variantName = variant?.capitalized()
val lightsaberCheck = registerTask(extension, variantName.orEmpty())
lightsaberCheck.configure { task ->
val taskProvider = provider {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package schwarz.it.lightsaber.gradle.processors

import com.android.build.api.variant.Variant
import org.gradle.api.Project
import org.gradle.api.tasks.TaskProvider
import org.jetbrains.kotlin.gradle.plugin.KaptExtension
Expand All @@ -14,9 +13,9 @@ import schwarz.it.lightsaber.gradle.registerTask

internal fun Project.registerKaptTask(
extension: LightsaberExtension,
variant: Variant? = null,
variant: String? = null,
): TaskProvider<LightsaberTask> {
val variantName = variant?.name?.capitalized()
val variantName = variant?.capitalized()
val lightsaberCheck = registerTask(extension, variantName.orEmpty())
lightsaberCheck.configure { task ->
val taskProvider = provider {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package schwarz.it.lightsaber.gradle.processors

import com.android.build.api.variant.Variant
import com.google.devtools.ksp.gradle.KspExtension
import com.google.devtools.ksp.gradle.KspTaskJvm
import org.gradle.api.Project
Expand All @@ -14,9 +13,9 @@ import schwarz.it.lightsaber.gradle.registerTask

internal fun Project.registerKspTask(
extension: LightsaberExtension,
variant: Variant? = null,
variant: String? = null,
): TaskProvider<LightsaberTask> {
val variantName = variant?.name?.capitalized()
val variantName = variant?.capitalized()
val lightsaberCheck = registerTask(extension, variantName.orEmpty())
lightsaberCheck.configure { task ->
val taskProvider = provider {
Expand Down

0 comments on commit 34377e7

Please sign in to comment.