From c18c9d7bbac93fb42c5b3af6caf1fe6adc755278 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Tue, 20 Jun 2023 12:32:56 +0530 Subject: [PATCH] Fixes for some Lint options have been deprecated in newer Gradle versions. We have introduced a new method, configureCommonExtension, in the AllProjectConfigurer.kt file since Lint is only available in CommonExtension. This allows us to configure Lint in one place for every module. Previously, we couldn't directly use Lint in the android-library project, but with this approach, we can now configure Lint for the android-library project as well. --- app/build.gradle.kts | 2 +- .../kotlin/plugin/AllProjectConfigurer.kt | 59 ++++++++++--------- .../kotlin/plugin/KiwixConfigurationPlugin.kt | 3 +- custom/build.gradle.kts | 2 +- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 71394cd57..839d58a39 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -73,7 +73,7 @@ android { } create("nightly") { initWith(getByName("debug")) - setMatchingFallbacks("debug") + matchingFallbacks += "debug" } } bundle { diff --git a/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt b/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt index 7f2cdcba0..468574d82 100644 --- a/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt +++ b/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt @@ -20,6 +20,7 @@ package plugin import Config import Libs +import com.android.build.api.dsl.CommonExtension import com.android.build.gradle.BaseExtension import io.gitlab.arturbosch.detekt.extensions.DetektExtension import org.gradle.api.Project @@ -42,7 +43,7 @@ class AllProjectConfigurer { target.plugins.apply("androidx.navigation.safeargs") } - fun configureBaseExtension(target: Project, path: String) { + fun configureBaseExtension(target: Project) { target.configureExtension { setCompileSdkVersion(Config.compileSdk) defaultConfig { @@ -89,32 +90,6 @@ class AllProjectConfigurer { } } } - - lintOptions { - isAbortOnError = true - isCheckAllWarnings = true - isWarningsAsErrors = true - - ignore( - "SyntheticAccessor", - "GoogleAppIndexingApiWarning", - "LockedOrientationActivity", - //TODO stop ignoring below this - "LabelFor", - "LogConditional", - "ConvertToWebp", - "UnknownNullness", - "SelectableText", - "MissingTranslation", - "IconDensities", - "ContentDescription", - "IconDipSize", - "UnusedResources", - "NonConstantResourceId", - "NotifyDataSetChanged" - ) - lintConfig = target.rootProject.file("lintConfig.xml") - } packagingOptions { resources.excludes.apply { add("META-INF/DEPENDENCIES") @@ -139,6 +114,36 @@ class AllProjectConfigurer { } } + fun configureCommonExtension(target: Project) { + target.configureExtension> { + lint { + abortOnError = true + checkAllWarnings = true + warningsAsErrors = true + + disable.apply { + add("SyntheticAccessor") + add("GoogleAppIndexingApiWarning") + add("LockedOrientationActivity") + // TODO stop ignoring below this + add("LabelFor") + add("LogConditional") + add("ConvertToWebp") + add("UnknownNullness") + add("SelectableText") + add("MissingTranslation") + add("IconDensities") + add("ContentDescription") + add("IconDipSize") + add("UnusedResources") + add("NonConstantResourceId") + add("NotifyDataSetChanged") + } + lintConfig = target.rootProject.file("lintConfig.xml") + } + } + } + fun configureJacoco(target: Project) { target.configurations.all { resolutionStrategy { diff --git a/buildSrc/src/main/kotlin/plugin/KiwixConfigurationPlugin.kt b/buildSrc/src/main/kotlin/plugin/KiwixConfigurationPlugin.kt index b8c327659..855e973f8 100644 --- a/buildSrc/src/main/kotlin/plugin/KiwixConfigurationPlugin.kt +++ b/buildSrc/src/main/kotlin/plugin/KiwixConfigurationPlugin.kt @@ -48,6 +48,7 @@ class KiwixConfigurationPlugin : Plugin { } private fun doDefaultConfiguration(target: Project) { - allProjectConfigurer.configureBaseExtension(target, "${target.projectDir}") + allProjectConfigurer.configureBaseExtension(target) + allProjectConfigurer.configureCommonExtension(target) } } diff --git a/custom/build.gradle.kts b/custom/build.gradle.kts index f79ea04bd..a61eb5be1 100644 --- a/custom/build.gradle.kts +++ b/custom/build.gradle.kts @@ -19,7 +19,7 @@ android { applicationId = "org.kiwix" } - flavorDimensions("default") + flavorDimensions += "default" productFlavors.apply { CustomApps.createDynamically(project.file("src"), this) all {