Created
November 21, 2021 09:38
-
-
Save yenerm/f86ff0c9f7b289e1363d8935c6884bda to your computer and use it in GitHub Desktop.
CustomPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.android.build.api.variant.ApplicationAndroidComponentsExtension | |
import org.gradle.api.Plugin | |
import org.gradle.api.Project | |
class CustomPlugin: Plugin<Project> { | |
override fun apply(project: Project) { | |
project.tasks.register("hello"){ task-> | |
task.doLast { | |
println("Hello " + project.parent?.name) | |
} | |
} | |
val extension = project.extensions.getByName("androidComponents") as ApplicationAndroidComponentsExtension | |
extension.beforeVariants { variantBuilder -> | |
if (variantBuilder.name == "staging") { | |
variantBuilder.enableUnitTest = false | |
variantBuilder.minSdk = 23 | |
} | |
} | |
extension.finalizeDsl { ext-> | |
ext.buildTypes.create("staging").let { buildType -> | |
buildType.initWith(ext.buildTypes.getByName("debug")) | |
buildType.manifestPlaceholders["hostName"] = "internal.example.com" | |
buildType.applicationIdSuffix = ".debugStaging" | |
//added later while explaining beforeVariants | |
buildType.isDebuggable = true | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment