From 9efbffe8c536c045334d6da186497e805f0934b8 Mon Sep 17 00:00:00 2001 From: John Shea Date: Tue, 20 Jun 2023 13:26:47 -0400 Subject: [PATCH] Migrate to Kotlin DSL (#57) --- app/build.gradle | 84 ------------------ app/build.gradle.kts | 87 +++++++++++++++++++ .../example/cupcake/ui/components/CommonUi.kt | 2 +- build.gradle => build.gradle.kts | 10 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle => settings.gradle.kts | 2 +- 6 files changed, 95 insertions(+), 92 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts rename build.gradle => build.gradle.kts (75%) rename settings.gradle => settings.gradle.kts (98%) diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 75e5ace..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2023 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 { - namespace 'com.example.cupcake' - compileSdk 33 - - defaultConfig { - applicationId "com.example.cupcake" - minSdk 24 - targetSdk 33 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary true - } - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - freeCompilerArgs += "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api" - } - buildFeatures { - compose true - } - composeOptions { - kotlinCompilerExtensionVersion '1.4.7' - } - packagingOptions { - resources { - excludes += '/META-INF/{AL2.0,LGPL2.1}' - } - } -} - -dependencies { - - implementation platform('androidx.compose:compose-bom:2023.05.00') - implementation 'androidx.activity:activity-compose:1.7.1' - implementation 'androidx.compose.material3:material3' - implementation 'androidx.compose.runtime:runtime' - implementation 'androidx.compose.runtime:runtime-livedata' - implementation 'androidx.compose.ui:ui' - implementation 'androidx.compose.ui:ui-graphics' - implementation 'androidx.compose.ui:ui-tooling-preview' - implementation 'androidx.core:core-ktx:1.10.0' - implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" - implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version" - implementation 'androidx.navigation:navigation-compose:2.5.3' - - debugImplementation 'androidx.compose.ui:ui-test-manifest' - debugImplementation 'androidx.compose.ui:ui-tooling' -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..a2ba8cd --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2023 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 { + namespace = "com.example.cupcake" + compileSdk = 33 + + defaultConfig { + applicationId = "com.example.cupcake" + minSdk = 24 + targetSdk = 33 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + freeCompilerArgs += "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api" + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.4.7" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + + implementation(platform("androidx.compose:compose-bom:2023.05.01")) + implementation("androidx.activity:activity-compose:1.7.2") + implementation("androidx.compose.material3:material3") + implementation("androidx.compose.runtime:runtime") + implementation("androidx.compose.runtime:runtime-livedata") + implementation("androidx.compose.ui:ui") + implementation("androidx.compose.ui:ui-graphics") + implementation("androidx.compose.ui:ui-tooling-preview") + implementation("androidx.core:core-ktx:1.10.1") + implementation("androidx.lifecycle:lifecycle-livedata-ktx:${rootProject.extra["lifecycle_version"]}") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:${rootProject.extra["lifecycle_version"]}") + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:${rootProject.extra["lifecycle_version"]}") + implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:${rootProject.extra["lifecycle_version"]}") + implementation("androidx.navigation:navigation-compose:2.5.3") + + debugImplementation("androidx.compose.ui:ui-test-manifest") + debugImplementation("androidx.compose.ui:ui-tooling") +} diff --git a/app/src/main/java/com/example/cupcake/ui/components/CommonUi.kt b/app/src/main/java/com/example/cupcake/ui/components/CommonUi.kt index 825635b..7a4fe0f 100644 --- a/app/src/main/java/com/example/cupcake/ui/components/CommonUi.kt +++ b/app/src/main/java/com/example/cupcake/ui/components/CommonUi.kt @@ -32,4 +32,4 @@ fun FormattedPriceLabel(subtotal: String, modifier: Modifier = Modifier) { modifier = modifier, style = MaterialTheme.typography.headlineSmall ) -} \ No newline at end of file +} diff --git a/build.gradle b/build.gradle.kts similarity index 75% rename from build.gradle rename to build.gradle.kts index 7454cbc..3a8f034 100644 --- a/build.gradle +++ b/build.gradle.kts @@ -15,12 +15,12 @@ */ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext { - lifecycle_version = "2.6.1" + extra.apply { + set("lifecycle_version", "2.6.1") } } plugins { - id 'com.android.application' version '8.0.1' apply false - id 'com.android.library' version '8.0.1' apply false - id 'org.jetbrains.kotlin.android' version '1.8.21' apply false + id("com.android.application") version "8.0.2" apply false + id("com.android.library") version "8.0.2" apply false + id("org.jetbrains.kotlin.android") version "1.8.21" apply false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8ffe776..3148757 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sun Mar 19 17:30:22 PDT 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle.kts similarity index 98% rename from settings.gradle rename to settings.gradle.kts index 2100ff1..d05ad38 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -28,4 +28,4 @@ dependencyResolutionManagement { } } rootProject.name = "Cupcake" -include ':app' +include(":app")