From c87d66750e644fce05f7630d3d235ae495faf23c Mon Sep 17 00:00:00 2001 From: dony <> Date: Thu, 11 Jul 2024 15:11:23 +0800 Subject: [PATCH] support productflavor --- .../ActivityThreadVariantProcessor.kt | 15 +++++++-------- .../FinalizerWatchdogDaemonVariantProcessor.kt | 14 +++++++------- .../transform/logcat/LogcatVariantProcessor.kt | 13 +++++++------ .../mediaplayer/MediaPlayerVariantProcessor.kt | 13 +++++++------ .../res/check/ResCheckVariantProcessor.kt | 13 +++++++------ .../transform/thread/ThreadVariantProcessor.kt | 13 +++++++------ .../transform/toast/ToastVariantProcessor.kt | 13 +++++++------ 7 files changed, 49 insertions(+), 45 deletions(-) diff --git a/booster-transform-activity-thread/src/main/kotlin/com/didiglobal/booster/transform/activitythread/ActivityThreadVariantProcessor.kt b/booster-transform-activity-thread/src/main/kotlin/com/didiglobal/booster/transform/activitythread/ActivityThreadVariantProcessor.kt index 2454ac28..da67cd36 100644 --- a/booster-transform-activity-thread/src/main/kotlin/com/didiglobal/booster/transform/activitythread/ActivityThreadVariantProcessor.kt +++ b/booster-transform-activity-thread/src/main/kotlin/com/didiglobal/booster/transform/activitythread/ActivityThreadVariantProcessor.kt @@ -1,9 +1,8 @@ package com.didiglobal.booster.transform.activitythread -import com.android.build.api.variant.DynamicFeatureVariantBuilder -import com.android.build.api.variant.LibraryVariantBuilder -import com.android.build.api.variant.VariantBuilder -import com.didiglobal.booster.gradle.* +import com.android.build.api.variant.DynamicFeatureVariant +import com.android.build.api.variant.LibraryVariant +import com.android.build.api.variant.Variant import com.didiglobal.booster.task.spi.VariantProcessor import com.didiglobal.booster.transform.activity.thread.Build.GROUP import com.didiglobal.booster.transform.activity.thread.Build.VERSION @@ -16,11 +15,11 @@ import org.gradle.api.Project @AutoService(VariantProcessor::class) class ActivityThreadVariantProcessor(private val project: Project) : VariantProcessor { - override fun beforeProcess(variantBuilder: VariantBuilder) { - if (variantBuilder is LibraryVariantBuilder || variantBuilder is DynamicFeatureVariantBuilder) { + override fun process(variant: Variant) { + super.process(variant) + if (variant is LibraryVariant || variant is DynamicFeatureVariant) { return } - project.dependencies.add("${variantBuilder.name}Implementation", "$GROUP:booster-android-instrument-activity-thread:$VERSION") + project.dependencies.add("${variant.name}Implementation", "$GROUP:booster-android-instrument-activity-thread:$VERSION") } - } diff --git a/booster-transform-finalizer-watchdog-daemon/src/main/kotlin/com/didiglobal/booster/transform/finalizer/watchdog/daemon/FinalizerWatchdogDaemonVariantProcessor.kt b/booster-transform-finalizer-watchdog-daemon/src/main/kotlin/com/didiglobal/booster/transform/finalizer/watchdog/daemon/FinalizerWatchdogDaemonVariantProcessor.kt index 9b23eebe..21155fda 100644 --- a/booster-transform-finalizer-watchdog-daemon/src/main/kotlin/com/didiglobal/booster/transform/finalizer/watchdog/daemon/FinalizerWatchdogDaemonVariantProcessor.kt +++ b/booster-transform-finalizer-watchdog-daemon/src/main/kotlin/com/didiglobal/booster/transform/finalizer/watchdog/daemon/FinalizerWatchdogDaemonVariantProcessor.kt @@ -1,8 +1,8 @@ package com.didiglobal.booster.transform.finalizer.watchdog.daemon -import com.android.build.api.variant.DynamicFeatureVariantBuilder -import com.android.build.api.variant.LibraryVariantBuilder -import com.android.build.api.variant.VariantBuilder +import com.android.build.api.variant.DynamicFeatureVariant +import com.android.build.api.variant.LibraryVariant +import com.android.build.api.variant.Variant import com.didiglobal.booster.task.spi.VariantProcessor import com.didiglobal.booster.transform.finalizer.watchdog.daemon.Build.GROUP import com.didiglobal.booster.transform.finalizer.watchdog.daemon.Build.VERSION @@ -15,12 +15,12 @@ import org.gradle.api.Project @AutoService(VariantProcessor::class) class FinalizerWatchdogDaemonVariantProcessor(private val project: Project) : VariantProcessor { - override fun beforeProcess(variantBuilder: VariantBuilder) { - if (variantBuilder is LibraryVariantBuilder || variantBuilder is DynamicFeatureVariantBuilder) { + override fun process(variant: Variant) { + super.process(variant) + if (variant is LibraryVariant || variant is DynamicFeatureVariant) { return } - project.dependencies.add("${variantBuilder.name}Implementation", "$GROUP:booster-android-instrument-finalizer-watchdog-daemon:$VERSION") - + project.dependencies.add("${variant.name}Implementation", "$GROUP:booster-android-instrument-finalizer-watchdog-daemon:$VERSION") } } diff --git a/booster-transform-logcat/src/main/kotlin/com/didiglobal/booster/transform/logcat/LogcatVariantProcessor.kt b/booster-transform-logcat/src/main/kotlin/com/didiglobal/booster/transform/logcat/LogcatVariantProcessor.kt index c7343fc1..0ca9ab3d 100644 --- a/booster-transform-logcat/src/main/kotlin/com/didiglobal/booster/transform/logcat/LogcatVariantProcessor.kt +++ b/booster-transform-logcat/src/main/kotlin/com/didiglobal/booster/transform/logcat/LogcatVariantProcessor.kt @@ -1,8 +1,8 @@ package com.didiglobal.booster.transform.logcat -import com.android.build.api.variant.DynamicFeatureVariantBuilder -import com.android.build.api.variant.LibraryVariantBuilder -import com.android.build.api.variant.VariantBuilder +import com.android.build.api.variant.DynamicFeatureVariant +import com.android.build.api.variant.LibraryVariant +import com.android.build.api.variant.Variant import com.didiglobal.booster.task.spi.VariantProcessor import com.didiglobal.booster.transform.logcat.Build.GROUP import com.didiglobal.booster.transform.logcat.Build.VERSION @@ -15,11 +15,12 @@ import org.gradle.api.Project @AutoService(VariantProcessor::class) class LogcatVariantProcessor(private val project: Project) : VariantProcessor { - override fun beforeProcess(variantBuilder: VariantBuilder) { - if (variantBuilder is LibraryVariantBuilder || variantBuilder is DynamicFeatureVariantBuilder) { + override fun process(variant: Variant) { + super.process(variant) + if (variant is LibraryVariant || variant is DynamicFeatureVariant) { return } - project.dependencies.add("${variantBuilder.name}Implementation", "$GROUP:booster-android-instrument-logcat:$VERSION") + project.dependencies.add("${variant.name}Implementation", "$GROUP:booster-android-instrument-logcat:$VERSION") } } diff --git a/booster-transform-media-player/src/main/kotlin/com/didiglobal/booster/transform/mediaplayer/MediaPlayerVariantProcessor.kt b/booster-transform-media-player/src/main/kotlin/com/didiglobal/booster/transform/mediaplayer/MediaPlayerVariantProcessor.kt index f446679d..d2efa215 100644 --- a/booster-transform-media-player/src/main/kotlin/com/didiglobal/booster/transform/mediaplayer/MediaPlayerVariantProcessor.kt +++ b/booster-transform-media-player/src/main/kotlin/com/didiglobal/booster/transform/mediaplayer/MediaPlayerVariantProcessor.kt @@ -1,8 +1,8 @@ package com.didiglobal.booster.transform.mediaplayer -import com.android.build.api.variant.DynamicFeatureVariantBuilder -import com.android.build.api.variant.LibraryVariantBuilder -import com.android.build.api.variant.VariantBuilder +import com.android.build.api.variant.DynamicFeatureVariant +import com.android.build.api.variant.LibraryVariant +import com.android.build.api.variant.Variant import com.didiglobal.booster.task.spi.VariantProcessor import com.didiglobal.booster.transform.media.player.Build.GROUP import com.didiglobal.booster.transform.media.player.Build.VERSION @@ -15,11 +15,12 @@ import org.gradle.api.Project @AutoService(VariantProcessor::class) class MediaPlayerVariantProcessor(private val project: Project) : VariantProcessor { - override fun beforeProcess(variantBuilder: VariantBuilder) { - if (variantBuilder is LibraryVariantBuilder || variantBuilder is DynamicFeatureVariantBuilder) { + override fun process(variant: Variant) { + super.process(variant) + if (variant is LibraryVariant || variant is DynamicFeatureVariant) { return } - project.dependencies.add("${variantBuilder.name}Implementation", "$GROUP:booster-android-instrument-media-player:$VERSION") + project.dependencies.add("${variant.name}Implementation", "$GROUP:booster-android-instrument-media-player:$VERSION") } } diff --git a/booster-transform-res-check/src/main/kotlin/com/didiglobal/booster/transform/res/check/ResCheckVariantProcessor.kt b/booster-transform-res-check/src/main/kotlin/com/didiglobal/booster/transform/res/check/ResCheckVariantProcessor.kt index e89faf94..51e4fa11 100644 --- a/booster-transform-res-check/src/main/kotlin/com/didiglobal/booster/transform/res/check/ResCheckVariantProcessor.kt +++ b/booster-transform-res-check/src/main/kotlin/com/didiglobal/booster/transform/res/check/ResCheckVariantProcessor.kt @@ -1,8 +1,8 @@ package com.didiglobal.booster.transform.res.check -import com.android.build.api.variant.DynamicFeatureVariantBuilder -import com.android.build.api.variant.LibraryVariantBuilder -import com.android.build.api.variant.VariantBuilder +import com.android.build.api.variant.DynamicFeatureVariant +import com.android.build.api.variant.LibraryVariant +import com.android.build.api.variant.Variant import com.didiglobal.booster.task.spi.VariantProcessor import com.didiglobal.booster.transform.res.check.Build.GROUP import com.didiglobal.booster.transform.res.check.Build.VERSION @@ -15,11 +15,12 @@ import org.gradle.api.Project @AutoService(VariantProcessor::class) class ResCheckVariantProcessor(private val project: Project) : VariantProcessor { - override fun beforeProcess(variantBuilder: VariantBuilder) { - if (variantBuilder is LibraryVariantBuilder || variantBuilder is DynamicFeatureVariantBuilder) { + override fun process(variant: Variant) { + super.process(variant) + if (variant is LibraryVariant || variant is DynamicFeatureVariant) { return } - project.dependencies.add("${variantBuilder.name}Implementation", "$GROUP:booster-android-instrument-res-check:$VERSION") + project.dependencies.add("${variant.name}Implementation", "$GROUP:booster-android-instrument-res-check:$VERSION") } } diff --git a/booster-transform-thread/src/main/kotlin/com/didiglobal/booster/transform/thread/ThreadVariantProcessor.kt b/booster-transform-thread/src/main/kotlin/com/didiglobal/booster/transform/thread/ThreadVariantProcessor.kt index aa5a01ab..6794ed55 100644 --- a/booster-transform-thread/src/main/kotlin/com/didiglobal/booster/transform/thread/ThreadVariantProcessor.kt +++ b/booster-transform-thread/src/main/kotlin/com/didiglobal/booster/transform/thread/ThreadVariantProcessor.kt @@ -1,8 +1,8 @@ package com.didiglobal.booster.transform.thread -import com.android.build.api.variant.DynamicFeatureVariantBuilder -import com.android.build.api.variant.LibraryVariantBuilder -import com.android.build.api.variant.VariantBuilder +import com.android.build.api.variant.DynamicFeatureVariant +import com.android.build.api.variant.LibraryVariant +import com.android.build.api.variant.Variant import com.didiglobal.booster.task.spi.VariantProcessor import com.didiglobal.booster.transform.thread.Build.GROUP import com.didiglobal.booster.transform.thread.Build.VERSION @@ -12,11 +12,12 @@ import org.gradle.api.Project @AutoService(VariantProcessor::class) class ThreadVariantProcessor(private val project: Project) : VariantProcessor { - override fun beforeProcess(variantBuilder: VariantBuilder) { - if (variantBuilder is LibraryVariantBuilder || variantBuilder is DynamicFeatureVariantBuilder) { + override fun process(variant: Variant) { + super.process(variant) + if (variant is LibraryVariant || variant is DynamicFeatureVariant) { return } - project.dependencies.add("${variantBuilder.name}Implementation", "$GROUP:booster-android-instrument-thread:$VERSION") + project.dependencies.add("${variant.name}Implementation", "$GROUP:booster-android-instrument-thread:$VERSION") } } diff --git a/booster-transform-toast/src/main/kotlin/com/didiglobal/booster/transform/toast/ToastVariantProcessor.kt b/booster-transform-toast/src/main/kotlin/com/didiglobal/booster/transform/toast/ToastVariantProcessor.kt index 45170a98..282690e4 100644 --- a/booster-transform-toast/src/main/kotlin/com/didiglobal/booster/transform/toast/ToastVariantProcessor.kt +++ b/booster-transform-toast/src/main/kotlin/com/didiglobal/booster/transform/toast/ToastVariantProcessor.kt @@ -1,8 +1,8 @@ package com.didiglobal.booster.transform.toast -import com.android.build.api.variant.DynamicFeatureVariantBuilder -import com.android.build.api.variant.LibraryVariantBuilder -import com.android.build.api.variant.VariantBuilder +import com.android.build.api.variant.DynamicFeatureVariant +import com.android.build.api.variant.LibraryVariant +import com.android.build.api.variant.Variant import com.didiglobal.booster.task.spi.VariantProcessor import com.didiglobal.booster.transform.toast.Build.GROUP import com.didiglobal.booster.transform.toast.Build.VERSION @@ -12,11 +12,12 @@ import org.gradle.api.Project @AutoService(VariantProcessor::class) class ToastVariantProcessor(private val project: Project) : VariantProcessor { - override fun beforeProcess(variantBuilder: VariantBuilder) { - if (variantBuilder is LibraryVariantBuilder || variantBuilder is DynamicFeatureVariantBuilder) { + override fun process(variant: Variant) { + super.process(variant) + if (variant is LibraryVariant || variant is DynamicFeatureVariant) { return } - project.dependencies.add("${variantBuilder.name}Implementation", "$GROUP:booster-android-instrument-toast:$VERSION") + project.dependencies.add("${variant.name}Implementation", "$GROUP:booster-android-instrument-toast:$VERSION") } }