From 3d7dd46fd59a9930c3a3b5a9cc6a89534005af23 Mon Sep 17 00:00:00 2001 From: Michael Stillwell Date: Thu, 18 Jul 2024 14:57:43 +0100 Subject: [PATCH 1/3] Migrate build scripts to Kotlin DSL --- WearTilesKotlin/app/build.gradle | 85 ------------------- WearTilesKotlin/app/build.gradle.kts | 85 +++++++++++++++++++ WearTilesKotlin/app/proguard-rules.pro | 4 +- .../{build.gradle => build.gradle.kts} | 16 ++-- 4 files changed, 95 insertions(+), 95 deletions(-) delete mode 100644 WearTilesKotlin/app/build.gradle create mode 100644 WearTilesKotlin/app/build.gradle.kts rename WearTilesKotlin/{build.gradle => build.gradle.kts} (72%) diff --git a/WearTilesKotlin/app/build.gradle b/WearTilesKotlin/app/build.gradle deleted file mode 100644 index fb81b6f42..000000000 --- a/WearTilesKotlin/app/build.gradle +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' -} - -android { - compileSdk 34 - - namespace "com.example.wear.tiles" - - defaultConfig { - applicationId "com.example.wear.tiles" - minSdk 26 - targetSdk 33 - versionCode 1 - versionName "1.0" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - coreLibraryDesugaringEnabled true - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.majorVersion - freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" - freeCompilerArgs += "-opt-in=com.google.android.horologist.annotations.ExperimentalHorologistApi" - } - - buildFeatures { - compose true - } - - composeOptions { - kotlinCompilerExtensionVersion libs.versions.compose.compiler.get() - } -} - -dependencies { - implementation libs.androidx.lifecycle.runtime.ktx - implementation libs.androidx.lifecycle.viewmodel.ktx - implementation libs.androidx.datastore - - implementation libs.androidx.wear.tiles.material - - implementation libs.coil - implementation libs.kotlinx.coroutines.android - implementation libs.kotlinx.coroutines.guava - - implementation libs.horologist.compose.tools - implementation libs.horologist.tiles - - implementation libs.androidx.wear.tooling.preview - implementation libs.compose.ui.tooling.preview - - coreLibraryDesugaring libs.desugar.jdk.libs - - debugImplementation libs.androidx.ui.tooling - debugImplementation libs.androidx.tiles.tooling.preview - debugImplementation libs.androidx.tiles.tooling -} diff --git a/WearTilesKotlin/app/build.gradle.kts b/WearTilesKotlin/app/build.gradle.kts new file mode 100644 index 000000000..7da31a0bf --- /dev/null +++ b/WearTilesKotlin/app/build.gradle.kts @@ -0,0 +1,85 @@ +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = 34 + + namespace = "com.example.wear.tiles" + + defaultConfig { + applicationId = "com.example.wear.tiles" + minSdk = 26 + targetSdk = 33 + versionCode = 1 + versionName = "1.0" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + isCoreLibraryDesugaringEnabled = true + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.majorVersion + freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" + freeCompilerArgs += "-opt-in=com.google.android.horologist.annotations.ExperimentalHorologistApi" + } + + buildFeatures { + compose = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get() + } +} + +dependencies { + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.ktx) + implementation(libs.androidx.datastore) + + implementation(libs.androidx.wear.tiles.material) + + implementation(libs.coil) + implementation(libs.kotlinx.coroutines.android) + implementation(libs.kotlinx.coroutines.guava) + + implementation(libs.horologist.compose.tools) + implementation(libs.horologist.tiles) + + implementation(libs.androidx.wear.tooling.preview) + implementation(libs.compose.ui.tooling.preview) + + coreLibraryDesugaring(libs.desugar.jdk.libs) + + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.tiles.tooling.preview) + debugImplementation(libs.androidx.tiles.tooling) +} diff --git a/WearTilesKotlin/app/proguard-rules.pro b/WearTilesKotlin/app/proguard-rules.pro index 481bb4348..2f9dc5a47 100644 --- a/WearTilesKotlin/app/proguard-rules.pro +++ b/WearTilesKotlin/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html @@ -18,4 +18,4 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile diff --git a/WearTilesKotlin/build.gradle b/WearTilesKotlin/build.gradle.kts similarity index 72% rename from WearTilesKotlin/build.gradle rename to WearTilesKotlin/build.gradle.kts index de553d7eb..401268e1d 100644 --- a/WearTilesKotlin/build.gradle +++ b/WearTilesKotlin/build.gradle.kts @@ -16,7 +16,7 @@ buildscript { dependencies { - classpath libs.kotlin.gradle.plugin + classpath(libs.kotlin.gradle.plugin) } } @@ -26,21 +26,21 @@ plugins { } subprojects { - apply plugin: "com.diffplug.spotless" - spotless { + apply(plugin = "com.diffplug.spotless") + configure { kotlin { - target "**/*.kt" + target("**/*.kt") targetExclude("$buildDir/**/*.kt") targetExclude("bin/**/*.kt") ktlint(libs.versions.ktlint.get()) - licenseHeaderFile rootProject.file("../spotless/copyright.kt") + licenseHeaderFile(rootProject.file("../spotless/copyright.kt")) } format("xml") { - target('**/*.xml') - targetExclude('**/build/**/*.xml') + target("**/*.xml") + targetExclude("**/build/**/*.xml") // Look for the first XML tag that isn't a comment (