diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7d40b533b64..cb9ecde2cc4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -2,21 +2,20 @@ import com.github.triplet.gradle.androidpublisher.ResolutionStrategy import com.google.gms.googleservices.GoogleServicesPlugin.GoogleServicesPluginConfig plugins { - id("com.android.application") - id("kotlin-android") - id("kotlin-kapt") - id("kotlin-parcelize") - id("com.google.firebase.appdistribution") - id("com.github.triplet.play") - id("com.google.gms.google-services") - kotlin("kapt") - id("dagger.hilt.android.plugin") + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.kapt) + alias(libs.plugins.kotlin.parcelize) + alias(libs.plugins.firebase.appdistribution) + alias(libs.plugins.play.publisher) + alias(libs.plugins.google.services) + alias(libs.plugins.hilt) } android { namespace = "io.homeassistant.companion.android" - compileSdk = 33 + compileSdk = libs.versions.androidSdk.compile.get().toInt() ndkVersion = "21.3.6528147" @@ -24,8 +23,8 @@ android { defaultConfig { applicationId = "io.homeassistant.companion.android" - minSdk = 21 - targetSdk = 33 + minSdk = libs.versions.androidSdk.min.get().toInt() + targetSdk = libs.versions.androidSdk.target.get().toInt() versionName = project.version.toString() versionCode = System.getenv("VERSION_CODE")?.toIntOrNull() ?: 1 @@ -50,12 +49,12 @@ android { } kotlinOptions { - jvmTarget = "11" + jvmTarget = libs.versions.javaVersion.get() } compileOptions { - sourceCompatibility(JavaVersion.VERSION_11) - targetCompatibility(JavaVersion.VERSION_11) + sourceCompatibility(libs.versions.javaVersion.get()) + targetCompatibility(libs.versions.javaVersion.get()) } firebaseAppDistribution { diff --git a/automotive/build.gradle.kts b/automotive/build.gradle.kts index b79d42e57c4..1f595508d6b 100644 --- a/automotive/build.gradle.kts +++ b/automotive/build.gradle.kts @@ -2,20 +2,19 @@ import com.github.triplet.gradle.androidpublisher.ResolutionStrategy import com.google.gms.googleservices.GoogleServicesPlugin.GoogleServicesPluginConfig plugins { - id("com.android.application") - id("kotlin-android") - id("kotlin-kapt") - id("kotlin-parcelize") - id("com.github.triplet.play") - id("com.google.gms.google-services") - kotlin("kapt") - id("dagger.hilt.android.plugin") + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.kapt) + alias(libs.plugins.kotlin.parcelize) + alias(libs.plugins.play.publisher) + alias(libs.plugins.google.services) + alias(libs.plugins.hilt) } android { namespace = "io.homeassistant.companion.android" - compileSdk = 33 + compileSdk = libs.versions.androidSdk.compile.get().toInt() ndkVersion = "21.3.6528147" @@ -23,8 +22,8 @@ android { defaultConfig { applicationId = "io.homeassistant.companion.android" - minSdk = 29 - targetSdk = 33 + minSdk = libs.versions.androidSdk.automotive.min.get().toInt() + targetSdk = libs.versions.androidSdk.target.get().toInt() versionName = project.version.toString() // We add 2 because the app, wear (+1) and automotive versions need to have different version codes. @@ -85,12 +84,12 @@ android { } kotlinOptions { - jvmTarget = "11" + jvmTarget = libs.versions.javaVersion.get() } compileOptions { - sourceCompatibility(JavaVersion.VERSION_11) - targetCompatibility(JavaVersion.VERSION_11) + sourceCompatibility(libs.versions.javaVersion.get()) + targetCompatibility(libs.versions.javaVersion.get()) } signingConfigs { diff --git a/build.gradle.kts b/build.gradle.kts index 9777b1e3578..71c718aabaa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,30 +2,24 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { alias(libs.plugins.ktlint) -} -buildscript { - repositories { - google() - gradlePluginPortal() - } - dependencies { - classpath(libs.android.plugin) - classpath(libs.kotlin.gradle.plugin) - classpath(libs.google.services) - classpath(libs.firebase.appdistribution.gradle) - classpath(libs.android.junit5) - classpath(libs.play.publisher) - classpath(libs.hilt.android.gradle.plugin) - } + alias(libs.plugins.android.application).apply(false) + alias(libs.plugins.android.library).apply(false) + alias(libs.plugins.kotlin.android).apply(false) + alias(libs.plugins.google.services).apply(false) + alias(libs.plugins.firebase.appdistribution).apply(false) + alias(libs.plugins.play.publisher).apply(false) + alias(libs.plugins.hilt).apply(false) + alias(libs.plugins.kotlin.kapt).apply(false) + alias(libs.plugins.kotlin.parcelize).apply(false) } allprojects { - apply(plugin = "org.jlleitschuh.gradle.ktlint") + apply(plugin = rootProject.libs.plugins.ktlint.get().pluginId) tasks.withType().configureEach { kotlinOptions { - jvmTarget = "11" + jvmTarget = libs.versions.javaVersion.get() } } } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 379de03482e..5bf7a61580a 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,9 +1,8 @@ plugins { - id("com.android.library") - id("kotlin-android") - id("kotlin-kapt") - kotlin("kapt") - id("dagger.hilt.android.plugin") + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.kapt) + alias(libs.plugins.hilt) } val homeAssistantAndroidPushUrl: String by project @@ -15,10 +14,10 @@ val versionCode = System.getenv("VERSION_CODE")?.toIntOrNull() ?: 1 android { namespace = "io.homeassistant.companion.android.common" - compileSdk = 33 + compileSdk = libs.versions.androidSdk.compile.get().toInt() defaultConfig { - minSdk = 21 + minSdk = libs.versions.androidSdk.min.get().toInt() buildConfigField("String", "PUSH_URL", "\"$homeAssistantAndroidPushUrl\"") buildConfigField("String", "RATE_LIMIT_URL", "\"$homeAssistantAndroidRateLimitUrl\"") buildConfigField("String", "VERSION_NAME", "\"$versionName-$versionCode\"") @@ -36,12 +35,12 @@ android { } kotlinOptions { - jvmTarget = "11" + jvmTarget = libs.versions.javaVersion.get() } compileOptions { - sourceCompatibility(JavaVersion.VERSION_11) - targetCompatibility(JavaVersion.VERSION_11) + sourceCompatibility(libs.versions.javaVersion.get()) + targetCompatibility(libs.versions.javaVersion.get()) } lint { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 33ded3396a3..b43809414f7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,13 @@ accompanist = "0.30.1" activity-compose = "1.7.2" androidBeaconLibrary = "2.19.6" androidJunit5 = "1.9.3.0" -androidPlugin = "8.0.2" +androidPlugin = "8.1.0" +androidSdk-compile = "33" +androidSdk-min = "23" +androidSdk-target = "33" +androidSdk-automotive-min = "29" +androidSdk-wear-min = "26" +androidSdk-wear-target = "32" appcompat = "1.6.1" biometric = "1.1.0" blurView = "version-1.6.6" @@ -27,6 +33,7 @@ healthServicesClient = "1.0.0-rc01" hilt = "2.47" iconics = "5.4.0" jackson-module-kotlin = "2.13.5" +javaVersion = "11" kotlinx-coroutines = "1.7.3" kotlin = "1.8.22" ktlint = "11.5.0" @@ -58,7 +65,16 @@ wear-remote-interactions = "1.0.0" workRuntimeKtx = "2.8.1" [plugins] +android-application = { id = "com.android.application", version.ref = "androidPlugin" } +android-library = { id = "com.android.library", version.ref = "androidPlugin" } +firebase-appdistribution = { id = "com.google.firebase.appdistribution", version.ref = "firebaseAppdistributionGradle" } +google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" } +hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } +kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } +play-publisher = { id = "com.github.triplet.play", version.ref = "playPublisher" } [libraries] accompanist-themeadapter-material = { module = "com.google.accompanist:accompanist-themeadapter-material", version.ref = "accompanist" } @@ -66,8 +82,6 @@ accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist- activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity-compose" } activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "activity-compose" } android-beacon-library = { module = "org.altbeacon:android-beacon-library", version.ref = "androidBeaconLibrary" } -android-plugin = { module = "com.android.tools.build:gradle", version.ref = "androidPlugin" } -android-junit5 = { module = "de.mannodermaus.gradle.plugins:android-junit5", version.ref = "androidJunit5" } androidx-health-services-client = { module = "androidx.health:health-services-client", version.ref = "healthServicesClient" } androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" } androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" } @@ -102,20 +116,16 @@ extension-cronet = { module = "com.google.android.exoplayer:extension-cronet", v exoplayer-ui = { module = "com.google.android.exoplayer:exoplayer-ui", version.ref = "exoplayer" } exoplayer-hls = { module = "com.google.android.exoplayer:exoplayer-hls", version.ref = "exoplayer" } exoplayer-core = { module = "com.google.android.exoplayer:exoplayer-core", version.ref = "exoplayer" } -firebase-appdistribution-gradle = { module = "com.google.firebase:firebase-appdistribution-gradle", version.ref = "firebaseAppdistributionGradle" } firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebase-bom" } firebase-messaging = { module = "com.google.firebase:firebase-messaging" } fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "fragment-ktx" } constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" } -google-services = { module = "com.google.gms:google-services", version.ref = "googleServices" } guava = { module = "com.google.guava:guava", version.ref = "guava" } hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" } hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" } -hilt-android-gradle-plugin = { module = "com.google.dagger:hilt-android-gradle-plugin", version.ref = "hilt" } iconics-compose = { module = "com.mikepenz:iconics-compose", version.ref = "iconics" } iconics-core = { module = "com.mikepenz:iconics-core", version.ref = "iconics" } jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson-module-kotlin" } -kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlinx-coroutines-guava = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-guava", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-play-services = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" } @@ -126,7 +136,6 @@ logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", ver navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation-compose" } okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } material = { module = "com.google.android.material:material", version.ref = "material" } -play-publisher = { module = "com.github.triplet.gradle:play-publisher", version.ref = "playPublisher" } play-services-threadnetwork = { module = "com.google.android.gms:play-services-threadnetwork", version.ref = "play-services-threadnetwork" } play-services-home = { module = "com.google.android.gms:play-services-home", version.ref = "play-services-home" } play-services-location = { module = "com.google.android.gms:play-services-location", version.ref = "play-services-location" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 56ecc7acf01..b63c69613d6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,27 +1,18 @@ -import org.gradle.kotlin.dsl.support.serviceOf include(":common", ":app", ":wear", ":automotive") rootProject.name = "home-assistant-android" -plugins { - id("com.gradle.enterprise").version("3.7") - id("org.ajoberstar.reckon.settings").version("0.18.0") +pluginManagement { + repositories { + gradlePluginPortal() + google() + } } -// It should be easier to read an environment variable here once github.com/gradle/configuration-cache/issues/211 is resolved. -val isCI = serviceOf() - .environmentVariable("CI") - .forUseAtConfigurationTime().map { it == "true" } - .getOrElse(false) - -gradleEnterprise { - buildScan { - termsOfServiceUrl = "https://gradle.com/terms-of-service" - termsOfServiceAgree = "yes" - publishAlwaysIf(isCI) - isUploadInBackground = !isCI - } +plugins { + // So we can't reach the libs.plugins.* aliases from here so we need to declare them the old way... + id("org.ajoberstar.reckon.settings").version("0.18.0") } extensions.configure { diff --git a/wear/build.gradle.kts b/wear/build.gradle.kts index 666d6b23782..4b4fc55b0f0 100644 --- a/wear/build.gradle.kts +++ b/wear/build.gradle.kts @@ -1,22 +1,21 @@ plugins { - id("com.android.application") - id("kotlin-android") - id("kotlin-kapt") - id("com.github.triplet.play") - kotlin("kapt") - id("dagger.hilt.android.plugin") - id("com.google.gms.google-services") + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.kapt) + alias(libs.plugins.play.publisher) + alias(libs.plugins.hilt) + alias(libs.plugins.google.services) } android { namespace = "io.homeassistant.companion.android" - compileSdk = 33 + compileSdk = libs.versions.androidSdk.compile.get().toInt() defaultConfig { applicationId = "io.homeassistant.companion.android" - minSdk = 26 - targetSdk = 32 + minSdk = libs.versions.androidSdk.wear.min.get().toInt() + targetSdk = libs.versions.androidSdk.wear.target.get().toInt() versionName = project.version.toString() // We add 1 because the app and wear versions need to have different version codes. @@ -61,12 +60,12 @@ android { } kotlinOptions { - jvmTarget = "11" + jvmTarget = libs.versions.javaVersion.get() } compileOptions { - sourceCompatibility(JavaVersion.VERSION_11) - targetCompatibility(JavaVersion.VERSION_11) + sourceCompatibility(libs.versions.javaVersion.get()) + targetCompatibility(libs.versions.javaVersion.get()) } lint {