diff --git a/plugins/src/main/kotlin/com/freeletics/gradle/monorepo/plugin/AppPlugin.kt b/plugins/src/main/kotlin/com/freeletics/gradle/monorepo/plugin/AppPlugin.kt index 231dcaf5..59c0b2c1 100644 --- a/plugins/src/main/kotlin/com/freeletics/gradle/monorepo/plugin/AppPlugin.kt +++ b/plugins/src/main/kotlin/com/freeletics/gradle/monorepo/plugin/AppPlugin.kt @@ -1,5 +1,6 @@ package com.freeletics.gradle.monorepo.plugin +import com.android.build.api.AndroidPluginVersion import com.freeletics.gradle.monorepo.setup.applyPlatformConstraints import com.freeletics.gradle.monorepo.setup.disableAndroidApplicationTasks import com.freeletics.gradle.monorepo.tasks.CheckDependencyRulesTask.Companion.registerCheckDependencyRulesTasks @@ -8,6 +9,7 @@ import com.freeletics.gradle.monorepo.util.appType import com.freeletics.gradle.plugin.FreeleticsAndroidAppPlugin import com.freeletics.gradle.util.androidApp import com.freeletics.gradle.util.androidComponents +import com.freeletics.gradle.util.androidPluginVersion import com.freeletics.gradle.util.freeleticsAndroidExtension import com.freeletics.gradle.util.freeleticsExtension import com.freeletics.gradle.util.stringProperty @@ -50,6 +52,11 @@ public abstract class AppPlugin : Plugin { } } + androidResources { + @Suppress("UnstableApiUsage") + generateLocaleConfig = target.androidPluginVersion >= AndroidPluginVersion(8, 2, 0).rc(1) + } + buildTypes { named("debug") { it.applicationIdSuffix = ".debug" diff --git a/plugins/src/main/kotlin/com/freeletics/gradle/monorepo/setup/DisableTasks.kt b/plugins/src/main/kotlin/com/freeletics/gradle/monorepo/setup/DisableTasks.kt index d289572c..7cae4452 100644 --- a/plugins/src/main/kotlin/com/freeletics/gradle/monorepo/setup/DisableTasks.kt +++ b/plugins/src/main/kotlin/com/freeletics/gradle/monorepo/setup/DisableTasks.kt @@ -1,7 +1,9 @@ package com.freeletics.gradle.monorepo.setup +import com.android.build.api.AndroidPluginVersion import com.android.build.api.variant.AndroidComponentsExtension import com.freeletics.gradle.monorepo.util.capitalize +import com.freeletics.gradle.util.androidPluginVersion import org.gradle.api.Project internal fun Project.disableAndroidApplicationTasks() { @@ -31,6 +33,11 @@ private fun Project.disableAndroidTasks(names: List, variantToKeep: Stri } private fun Project.disableTasks(names: List) { + // since AGP 8.3 the tasks.named will fail during project sync + if (providers.systemProperty("idea.sync.active").getOrElse("false").toBoolean()) { + return + } + afterEvaluate { names.forEach { name -> tasks.named(name).configure { @@ -53,12 +60,16 @@ private val androidLibraryTasksToDisable = listOf( // for libraries remove all reporting tasks so that they only // have the analyze task since we have an aggregated report at // the app level -private val androidLibraryLintTasksToDisable = listOf( +private val Project.androidLibraryLintTasksToDisable get() = listOf( // report "lint", "lint{VARIANT}", "lintReport{VARIANT}", - "copy{VARIANT}AndroidLintReports", + if (androidPluginVersion >= AndroidPluginVersion(8, 2, 0).rc(1)) { + "copy{VARIANT}LintReports" + } else { + "copy{VARIANT}AndroidLintReports" + }, // fix "lintFix", "lintFix{VARIANT}", @@ -74,13 +85,17 @@ private val androidLibraryLintTasksToDisableExceptOneVariant = listOf( ) // disable debug variant of these tasks, we're only running on release -private val androidAppLintTasksToDisableExceptOneVariant = listOf( +private val Project.androidAppLintTasksToDisableExceptOneVariant get() = listOf( // analyze "lintAnalyze{VARIANT}", // report "lint{VARIANT}", "lintReport{VARIANT}", - "copy{VARIANT}AndroidLintReports", + if (androidPluginVersion >= AndroidPluginVersion(8, 2, 0).rc(1)) { + "copy{VARIANT}LintReports" + } else { + "copy{VARIANT}AndroidLintReports" + }, // fix "lintFix{VARIANT}", // baseline @@ -89,14 +104,35 @@ private val androidAppLintTasksToDisableExceptOneVariant = listOf( // same as the Android library tasks, only keep analyze and the report // is created in the app module -private val lintTasksToDisableJvm = listOf( - "lint", - "lintReport", - "copyAndroidLintReports", - "lintFix", - "updateLintBaseline", - // TODO these shouldn't be created by AGP in the first place - "lintVital", - "lintVitalAnalyze", - "lintVitalReport", -) +private val Project.lintTasksToDisableJvm + get() = if (androidPluginVersion >= AndroidPluginVersion(8, 2, 0).rc(1)) { + listOf( + "lint", + "lintJvm", + "lintReportJvm", + "copyJvmLintReports", + "lintFix", + "lintFixJvm", + "updateLintBaseline", + "updateLintBaselineJvm", + "lintVital", + "lintVitalJvm", + if (androidPluginVersion >= AndroidPluginVersion(8, 3, 0).alpha(14)) { + "lintVitalAnalyzeJvm" + } else { + "lintVitalAnalyzeJvmMain" + }, + "lintVitalReportJvm", + ) + } else { + listOf( + "lint", + "lintReport", + "copyAndroidLintReports", + "lintFix", + "updateLintBaseline", + "lintVital", + "lintVitalAnalyze", + "lintVitalReport", + ) + } diff --git a/plugins/src/main/kotlin/com/freeletics/gradle/util/Extensions.kt b/plugins/src/main/kotlin/com/freeletics/gradle/util/Extensions.kt index ddd4ca05..d8e61390 100644 --- a/plugins/src/main/kotlin/com/freeletics/gradle/util/Extensions.kt +++ b/plugins/src/main/kotlin/com/freeletics/gradle/util/Extensions.kt @@ -1,5 +1,6 @@ package com.freeletics.gradle.util +import com.android.build.api.AndroidPluginVersion import com.android.build.api.dsl.ApplicationExtension import com.android.build.api.dsl.CommonExtension import com.android.build.api.dsl.LibraryExtension @@ -61,6 +62,9 @@ internal fun Project.androidApp(action: ApplicationExtension.() -> Unit) { } } +internal val Project.androidPluginVersion: AndroidPluginVersion + get() = extensions.getByType(AndroidComponentsExtension::class.java).pluginVersion + internal fun Project.androidComponents(action: AndroidComponentsExtension<*, *, *>.() -> Unit) { extensions.configure(AndroidComponentsExtension::class.java) { it.action()