Simon Marquis 3 weeks ago
parent 974d6b8de3
commit 859f5c6517

@ -37,7 +37,7 @@ kotlin {
} }
dependencies { dependencies {
compileOnly(libs.android.gradleApiPlugin) compileOnly(libs.android.gradlePlugin)
compileOnly(libs.android.tools.common) compileOnly(libs.android.tools.common)
compileOnly(libs.compose.gradlePlugin) compileOnly(libs.compose.gradlePlugin)
compileOnly(libs.firebase.crashlytics.gradlePlugin) compileOnly(libs.firebase.crashlytics.gradlePlugin)

@ -15,6 +15,7 @@
*/ */
import com.android.build.api.dsl.ApplicationExtension import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.variant.ApplicationAndroidComponentsExtension import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import com.google.samples.apps.nowinandroid.configureBadgingTasks import com.google.samples.apps.nowinandroid.configureBadgingTasks
import com.google.samples.apps.nowinandroid.configureGradleManagedDevices import com.google.samples.apps.nowinandroid.configureGradleManagedDevices
@ -30,7 +31,6 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
override fun apply(target: Project) { override fun apply(target: Project) {
with(target) { with(target) {
apply(plugin = "com.android.application") apply(plugin = "com.android.application")
apply(plugin = "org.jetbrains.kotlin.android")
apply(plugin = "nowinandroid.android.lint") apply(plugin = "nowinandroid.android.lint")
apply(plugin = "com.dropbox.dependency-guard") apply(plugin = "com.dropbox.dependency-guard")
@ -43,7 +43,7 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
} }
extensions.configure<ApplicationAndroidComponentsExtension> { extensions.configure<ApplicationAndroidComponentsExtension> {
configurePrintApksTask(this) configurePrintApksTask(this)
configureBadgingTasks(extensions.getByType<ApplicationExtension>(), this) configureBadgingTasks(extensions.getByType<CommonExtension>(), this)
} }
} }
} }

@ -28,7 +28,8 @@ class AndroidApplicationFirebaseConventionPlugin : Plugin<Project> {
override fun apply(target: Project) { override fun apply(target: Project) {
with(target) { with(target) {
apply(plugin = "com.google.gms.google-services") apply(plugin = "com.google.gms.google-services")
apply(plugin = "com.google.firebase.firebase-perf") // https://github.com/firebase/firebase-android-sdk/issues/7293
// apply(plugin = "com.google.firebase.firebase-perf")
apply(plugin = "com.google.firebase.crashlytics") apply(plugin = "com.google.firebase.crashlytics")
dependencies { dependencies {

@ -32,12 +32,10 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) { override fun apply(target: Project) {
with(target) { with(target) {
apply(plugin = "com.android.library") apply(plugin = "com.android.library")
apply(plugin = "org.jetbrains.kotlin.android")
apply(plugin = "nowinandroid.android.lint") apply(plugin = "nowinandroid.android.lint")
extensions.configure<LibraryExtension> { extensions.configure<LibraryExtension> {
configureKotlinAndroid(this) configureKotlinAndroid(this)
testOptions.targetSdk = 35
lint.targetSdk = 35 lint.targetSdk = 35
defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testOptions.animationsDisabled = true testOptions.animationsDisabled = true

@ -26,7 +26,6 @@ class AndroidTestConventionPlugin : Plugin<Project> {
override fun apply(target: Project) { override fun apply(target: Project) {
with(target) { with(target) {
apply(plugin = "com.android.test") apply(plugin = "com.android.test")
apply(plugin = "org.jetbrains.kotlin.android")
extensions.configure<TestExtension> { extensions.configure<TestExtension> {
configureKotlinAndroid(this) configureKotlinAndroid(this)

@ -28,12 +28,10 @@ import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginE
* Configure Compose-specific options * Configure Compose-specific options
*/ */
internal fun Project.configureAndroidCompose( internal fun Project.configureAndroidCompose(
commonExtension: CommonExtension<*, *, *, *, *, *>, commonExtension: CommonExtension,
) { ) {
commonExtension.apply { commonExtension.apply {
buildFeatures { buildFeatures.compose = true
compose = true
}
dependencies { dependencies {
val bom = libs.findLibrary("androidx-compose-bom").get() val bom = libs.findLibrary("androidx-compose-bom").get()

@ -18,7 +18,7 @@ package com.google.samples.apps.nowinandroid
import com.android.SdkConstants import com.android.SdkConstants
import com.android.build.api.artifact.SingleArtifact import com.android.build.api.artifact.SingleArtifact
import com.android.build.api.dsl.ApplicationExtension import com.android.build.api.dsl.CommonExtension
import com.android.build.api.variant.ApplicationAndroidComponentsExtension import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import com.google.common.truth.Truth.assertWithMessage import com.google.common.truth.Truth.assertWithMessage
import org.gradle.api.DefaultTask import org.gradle.api.DefaultTask
@ -110,7 +110,7 @@ private fun String.capitalized() = replaceFirstChar {
} }
fun Project.configureBadgingTasks( fun Project.configureBadgingTasks(
baseExtension: ApplicationExtension, baseExtension: CommonExtension,
componentsExtension: ApplicationAndroidComponentsExtension, componentsExtension: ApplicationAndroidComponentsExtension,
) { ) {
// Registers a callback to be called, when a new variant is configured // Registers a callback to be called, when a new variant is configured

@ -25,7 +25,7 @@ import org.gradle.kotlin.dsl.invoke
* Configure project for Gradle managed devices * Configure project for Gradle managed devices
*/ */
internal fun configureGradleManagedDevices( internal fun configureGradleManagedDevices(
commonExtension: CommonExtension<*, *, *, *, *, *>, commonExtension: CommonExtension,
) { ) {
val pixel4 = DeviceConfig("Pixel 4", 30, "aosp-atd") val pixel4 = DeviceConfig("Pixel 4", 30, "aosp-atd")
val pixel6 = DeviceConfig("Pixel 6", 31, "aosp") val pixel6 = DeviceConfig("Pixel 6", 31, "aosp")

@ -32,14 +32,12 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
* Configure base Kotlin with Android options * Configure base Kotlin with Android options
*/ */
internal fun Project.configureKotlinAndroid( internal fun Project.configureKotlinAndroid(
commonExtension: CommonExtension<*, *, *, *, *, *>, commonExtension: CommonExtension,
) { ) {
commonExtension.apply { commonExtension.apply {
compileSdk = 35 compileSdk = 35
defaultConfig { defaultConfig.minSdk = 23
minSdk = 23
}
compileOptions { compileOptions {
// Up to Java 11 APIs are available through desugaring // Up to Java 11 APIs are available through desugaring

@ -20,7 +20,7 @@ enum class NiaFlavor(val dimension: FlavorDimension, val applicationIdSuffix: St
} }
fun configureFlavors( fun configureFlavors(
commonExtension: CommonExtension<*, *, *, *, *, *>, commonExtension: CommonExtension,
flavorConfigurationBlock: ProductFlavor.(flavor: NiaFlavor) -> Unit = {}, flavorConfigurationBlock: ProductFlavor.(flavor: NiaFlavor) -> Unit = {},
) { ) {
commonExtension.apply { commonExtension.apply {
@ -28,15 +28,13 @@ fun configureFlavors(
flavorDimensions += flavorDimension.name flavorDimensions += flavorDimension.name
} }
productFlavors { NiaFlavor.values().forEach { niaFlavor ->
NiaFlavor.values().forEach { niaFlavor -> productFlavors.register(niaFlavor.name) {
register(niaFlavor.name) { dimension = niaFlavor.dimension.name
dimension = niaFlavor.dimension.name flavorConfigurationBlock(this, niaFlavor)
flavorConfigurationBlock(this, niaFlavor) if (this@apply is ApplicationExtension && this is ApplicationProductFlavor) {
if (this@apply is ApplicationExtension && this is ApplicationProductFlavor) { if (niaFlavor.applicationIdSuffix != null) {
if (niaFlavor.applicationIdSuffix != null) { applicationIdSuffix = niaFlavor.applicationIdSuffix
applicationIdSuffix = niaFlavor.applicationIdSuffix
}
} }
} }
} }

@ -2,8 +2,8 @@
accompanist = "0.37.0" accompanist = "0.37.0"
androidDesugarJdkLibs = "2.1.4" androidDesugarJdkLibs = "2.1.4"
# AGP and tools should be updated together # AGP and tools should be updated together
androidGradlePlugin = "8.12.2" androidGradlePlugin = "9.0.0-alpha05"
androidTools = "31.12.2" androidTools = "32.0.0-alpha05"
androidxActivity = "1.9.3" androidxActivity = "1.9.3"
androidxAppCompat = "1.7.0" androidxAppCompat = "1.7.0"
androidxBrowser = "1.8.0" androidxBrowser = "1.8.0"
@ -151,7 +151,7 @@ truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }
turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" } turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" }
# Dependencies of the included build-logic # Dependencies of the included build-logic
android-gradleApiPlugin = { group = "com.android.tools.build", name = "gradle-api", version.ref = "androidGradlePlugin" } android-gradlePlugin = { group = "com.android.tools.build", name = "gradle-api", version.ref = "androidGradlePlugin" }
android-tools-common = { group = "com.android.tools", name = "common", version.ref = "androidTools" } android-tools-common = { group = "com.android.tools", name = "common", version.ref = "androidTools" }
compose-gradlePlugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" } compose-gradlePlugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" }
firebase-crashlytics-gradlePlugin = { group = "com.google.firebase", name = "firebase-crashlytics-gradle", version.ref = "firebaseCrashlyticsPlugin" } firebase-crashlytics-gradlePlugin = { group = "com.google.firebase", name = "firebase-crashlytics-gradle", version.ref = "firebaseCrashlyticsPlugin" }

Loading…
Cancel
Save