fix(build): make slim tests optional

This commit is contained in:
Harsh Shandilya 2023-06-28 10:46:37 +05:30
parent d8a76cf1e7
commit c089e5ae5a
No known key found for this signature in database
3 changed files with 19 additions and 15 deletions

View file

@ -31,6 +31,7 @@ class AndroidCommonPlugin : Plugin<Project> {
const val COMPILE_SDK = 34
const val MIN_SDK = 26
const val TARGET_SDK = 34
const val SLIM_TESTS_PROPERTY = "slimTests"
}
override fun apply(project: Project) {
@ -68,22 +69,25 @@ class AndroidCommonPlugin : Plugin<Project> {
val libs = catalog.named("libs")
project.dependencies.addProvider("lintChecks", libs.findLibrary("slack-compose-lints").get())
}
}
private fun Project.configureSlimTests() {
// Disable unit test tasks on the release build type for Android Library projects
extensions.findByType<LibraryAndroidComponentsExtension>()?.run {
beforeVariants(selector().withBuildType("release")) {
(it as HasUnitTestBuilder).enableUnitTest = false
it.enableAndroidTest = false
private fun Project.configureSlimTests() {
if (!providers.gradleProperty(SLIM_TESTS_PROPERTY).isPresent) {
return
}
// Disable unit test tasks on the release build type for Android Library projects
extensions.findByType<LibraryAndroidComponentsExtension>()?.run {
beforeVariants(selector().withBuildType("release")) {
(it as HasUnitTestBuilder).enableUnitTest = false
it.enableAndroidTest = false
}
}
}
// Disable unit test tasks on the release build type for Android Application projects.
extensions.findByType<ApplicationAndroidComponentsExtension>()?.run {
beforeVariants(selector().withBuildType("release")) {
(it as HasUnitTestBuilder).enableUnitTest = false
it.enableAndroidTest = false
// Disable unit test tasks on the release build type for Android Application projects.
extensions.findByType<ApplicationAndroidComponentsExtension>()?.run {
beforeVariants(selector().withBuildType("release")) {
(it as HasUnitTestBuilder).enableUnitTest = false
it.enableAndroidTest = false
}
}
}
}