From 9ca0ba1c37a27b468887e78304c89ec009156589 Mon Sep 17 00:00:00 2001 From: Dale Hawkins <107309+dkhawk@users.noreply.github.com> Date: Fri, 1 Nov 2024 14:45:51 -0600 Subject: [PATCH] chore: update java demo build file to Kotlin and version catalog (#770) * chore: update java demo build file to Kotlin and version catalog * chore: updates the project name in the settings file --- demo-java/app/build.gradle | 60 ----------------- demo-java/app/build.gradle.kts | 65 +++++++++++++++++++ demo-java/app/proguard-rules.pro | 2 +- .../placesdemo/CurrentPlaceActivity.java | 2 +- demo-java/build.gradle | 23 ------- demo-java/build.gradle.kts | 6 ++ demo-java/gradle/libs.versions.toml | 36 ++++++++++ demo-java/settings.gradle | 24 ++++++- demo-kotlin/gradle/libs.versions.toml | 6 +- 9 files changed, 135 insertions(+), 89 deletions(-) delete mode 100644 demo-java/app/build.gradle create mode 100644 demo-java/app/build.gradle.kts delete mode 100644 demo-java/build.gradle create mode 100644 demo-java/build.gradle.kts create mode 100644 demo-java/gradle/libs.versions.toml diff --git a/demo-java/app/build.gradle b/demo-java/app/build.gradle deleted file mode 100644 index 2a05ad0f..00000000 --- a/demo-java/app/build.gradle +++ /dev/null @@ -1,60 +0,0 @@ -plugins { - id 'com.android.application' - id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' - id 'org.jetbrains.kotlin.android' version '1.6.21' apply false -} - -android { - compileSdk 34 - defaultConfig { - applicationId "com.example.placesdemo" - minSdkVersion 23 - targetSdkVersion 35 - multiDexEnabled true - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - namespace 'com.example.placesdemo' - - buildFeatures { - viewBinding true - } -} - -dependencies { - implementation 'androidx.appcompat:appcompat:1.7.0' - implementation 'com.google.android.material:material:1.12.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.navigation:navigation-fragment:2.8.1' - implementation 'androidx.navigation:navigation-ui:2.8.1' - implementation "androidx.activity:activity:1.9.2" - implementation "androidx.fragment:fragment:1.8.3" - implementation 'com.android.volley:volley:1.2.1' - implementation "com.github.bumptech.glide:glide:4.16.0" - implementation "com.android.databinding:viewbinding:8.6.1" - - // Places and Maps SDKs - implementation 'com.google.android.libraries.places:places:4.0.0' - implementation 'com.google.android.gms:play-services-maps:19.0.0' - implementation 'com.google.maps.android:android-maps-utils:3.8.2' -} - -secrets { - // To add your Google Maps Platform API key to this project: - // 1. Copy local.defaults.properties to secrets.properties - // 2. In the secrets.properties file, replace PLACES_API_KEY=DEFAULT_API_KEY with a key from a - // project with Places API enabled - // 3. In the secrets.properties file, replace MAPS_API_KEY=DEFAULT_API_KEY with a key from a - // project with Maps SDK for Android enabled (can be the same project and key as in Step 2) - defaultPropertiesFileName 'local.defaults.properties' - - // Optionally specify a different file name containing your secrets. - // The plugin defaults to "local.properties" - propertiesFileName = "secrets.properties" -} diff --git a/demo-java/app/build.gradle.kts b/demo-java/app/build.gradle.kts new file mode 100644 index 00000000..2a12acde --- /dev/null +++ b/demo-java/app/build.gradle.kts @@ -0,0 +1,65 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.secrets.gradle.plugin) +} + +android { + namespace = "com.example.placesdemo" + compileSdk = 35 + + defaultConfig { + applicationId = "com.example.placesdemo" + minSdk = 23 + targetSdk = 35 + versionCode = 1 + versionName = "1.0" + + multiDexEnabled = true + } + + java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + } + + buildFeatures { + viewBinding = true + } +} + +dependencies { + implementation(libs.constraintlayout) + implementation(libs.activity) + implementation(libs.fragment) + implementation(libs.navigation.fragment) + implementation(libs.navigation.ui) + + implementation(libs.appcompat) + implementation(libs.material) + + implementation(libs.volley) + implementation(libs.glide) + implementation(libs.viewbinding) + implementation(libs.multidex) + + // Places and Maps SDKs + implementation(libs.places) + implementation(libs.play.services.maps) + implementation(libs.android.maps.utils) +} + +// Secrets for Google Maps API Keys +secrets { + // To add your Google Maps Platform API key to this project: + // 1. Copy local.defaults.properties to secrets.properties + // 2. In the secrets.properties file, replace PLACES_API_KEY=DEFAULT_API_KEY with a key from a + // project with Places API enabled + // 3. In the secrets.properties file, replace MAPS_API_KEY=DEFAULT_API_KEY with a key from a + // project with Maps SDK for Android enabled (can be the same project and key as in Step 2) + defaultPropertiesFileName = "local.defaults.properties" + + // Optionally specify a different file name containing your secrets. + // The plugin defaults to "local.properties" + propertiesFileName = "secrets.properties" +} diff --git a/demo-java/app/proguard-rules.pro b/demo-java/app/proguard-rules.pro index f1b42451..2f9dc5a4 100644 --- a/demo-java/app/proguard-rules.pro +++ b/demo-java/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 diff --git a/demo-java/app/src/main/java/com/example/placesdemo/CurrentPlaceActivity.java b/demo-java/app/src/main/java/com/example/placesdemo/CurrentPlaceActivity.java index 4dcf0e8a..a8d39dc8 100644 --- a/demo-java/app/src/main/java/com/example/placesdemo/CurrentPlaceActivity.java +++ b/demo-java/app/src/main/java/com/example/placesdemo/CurrentPlaceActivity.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/demo-java/build.gradle b/demo-java/build.gradle deleted file mode 100644 index bbcd0cb5..00000000 --- a/demo-java/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - google() - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:8.6.1' - classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1" - } -} - -allprojects { - repositories { - google() - mavenCentral() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/demo-java/build.gradle.kts b/demo-java/build.gradle.kts new file mode 100644 index 00000000..c2e48593 --- /dev/null +++ b/demo-java/build.gradle.kts @@ -0,0 +1,6 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.secrets.gradle.plugin) apply false +} diff --git a/demo-java/gradle/libs.versions.toml b/demo-java/gradle/libs.versions.toml new file mode 100644 index 00000000..2c2e4460 --- /dev/null +++ b/demo-java/gradle/libs.versions.toml @@ -0,0 +1,36 @@ +[versions] +activity = "1.9.3" +androidGradlePlugin = "8.6.1" +androidMapsUtils = "3.8.2" +appcompat = "1.7.0" +constraintlayout = "2.2.0" +fragment = "1.8.5" +glide = "4.16.0" +mapsSecretsGradlePlugin = "2.0.1" +material = "1.12.0" +multidex = "2.0.1" +navigationFragment = "2.8.3" +places = "4.0.0" +playServicesMaps = "19.0.0" +viewbinding = "8.7.2" +volley = "1.2.1" + +[libraries] +activity = { module = "androidx.activity:activity", version.ref = "activity" } +android-maps-utils = { module = "com.google.maps.android:android-maps-utils", version.ref = "androidMapsUtils" } +appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } +constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" } +fragment = { module = "androidx.fragment:fragment", version.ref = "fragment" } +glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" } +material = { module = "com.google.android.material:material", version.ref = "material" } +multidex = { module = "androidx.multidex:multidex", version.ref = "multidex" } +navigation-fragment = { module = "androidx.navigation:navigation-fragment", version.ref = "navigationFragment" } +navigation-ui = { module = "androidx.navigation:navigation-ui", version.ref = "navigationFragment" } +places = { module = "com.google.android.libraries.places:places", version.ref = "places" } +play-services-maps = { module = "com.google.android.gms:play-services-maps", version.ref = "playServicesMaps" } +viewbinding = { module = "com.android.databinding:viewbinding", version.ref = "viewbinding" } +volley = { module = "com.android.volley:volley", version.ref = "volley" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } +secrets-gradle-plugin = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "mapsSecretsGradlePlugin" } diff --git a/demo-java/settings.gradle b/demo-java/settings.gradle index e7b4def4..7dbf4d04 100644 --- a/demo-java/settings.gradle +++ b/demo-java/settings.gradle @@ -1 +1,23 @@ -include ':app' +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "Android Places Java Demo" +include(":app") diff --git a/demo-kotlin/gradle/libs.versions.toml b/demo-kotlin/gradle/libs.versions.toml index 1dcd9aa5..109f0c71 100644 --- a/demo-kotlin/gradle/libs.versions.toml +++ b/demo-kotlin/gradle/libs.versions.toml @@ -1,15 +1,15 @@ [versions] androidGradlePlugin = "8.6.1" appcompat = "1.7.0" -coreKtx = "1.13.1" +coreKtx = "1.15.0" glide = "4.16.0" -kotlin = "2.0.0" +kotlin = "2.0.20" mapsSecretsGradlePlugin = "2.0.1" mapsUtilsKtx = "5.1.1" material = "1.12.0" multidex = "2.0.1" places = "4.0.0" -viewbinding = "8.6.1" +viewbinding = "8.7.2" volley = "1.2.1" kotlinParcelize = "1.9.24"