Merge "Update for Car App Library GitHub samples" into androidx-main am: 3777099476

Original change: https://android-review.googlesource.com/c/platform/frameworks/support/+/3155125

Change-Id: If702376d03b2cc66a49ca100ef737333060f21f9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/car/app/app-samples/github_build.gradle b/car/app/app-samples/github_build.gradle
index 4f83b4b..d1360f2 100644
--- a/car/app/app-samples/github_build.gradle
+++ b/car/app/app-samples/github_build.gradle
@@ -15,17 +15,16 @@
  */
 
 buildscript {
-
     repositories {
         google()
         mavenCentral()
+        gradlePluginPortal()
     }
-    dependencies {
-        classpath 'com.android.tools.build:gradle:8.4.2'
+}
 
-        // NOTE: Do not place your application dependencies here; they belong
-        // in the individual module build.gradle files
-    }
+plugins {
+    alias libs.plugins.android.application apply false
+    alias libs.plugins.android.library apply false
 }
 
 allprojects {
diff --git a/car/app/app-samples/github_settings.gradle b/car/app/app-samples/github_settings.gradle
index b2df5296..3e12259 100644
--- a/car/app/app-samples/github_settings.gradle
+++ b/car/app/app-samples/github_settings.gradle
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+pluginManagement {
+    repositories {
+        google()
+        mavenCentral()
+        gradlePluginPortal()
+    }
+}
+
 rootProject.name='car_app_samples'
 include ':navigation:automotive'
 include ':navigation:common'
diff --git a/car/app/app-samples/gradle/libs.versions.toml b/car/app/app-samples/gradle/libs.versions.toml
new file mode 100644
index 0000000..6c53058
--- /dev/null
+++ b/car/app/app-samples/gradle/libs.versions.toml
@@ -0,0 +1,26 @@
+[versions]
+java = "17"
+kotlin = "2.0.0"
+gradle = "8.4.2"
+androidGradlePlugin = "8.4.2"
+androidx-annotation-experimental = "1.4.1"
+androidx-core = "1.13.1"
+androidx-car = "1.7.0-beta01"
+androidx-constraintlayout = "2.1.4"
+core-ktx = "1.13.1"
+
+[libraries]
+androidx-car-app = { module = "androidx.car.app:app", version.ref = "androidx-car" }
+androidx-app-automotive = { module = "androidx.car.app:app-automotive", version.ref = "androidx-car" }
+androidx-app-projected = { module = "androidx.car.app:app-projected", version.ref = "androidx-car" }
+androidx-annotation-experimental = { module = "androidx.annotation:annotation-experimental", version.ref = "androidx-annotation-experimental" }
+androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintlayout" }
+androidx-core = { module = "androidx.core:core", version.ref = "androidx-core" }
+androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
+gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" }
+
+
+[plugins]
+jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
+android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
+android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
\ No newline at end of file
diff --git a/car/app/app-samples/navigation/automotive/github_build.gradle b/car/app/app-samples/navigation/automotive/github_build.gradle
index e3e7a7f..bd2fa01 100644
--- a/car/app/app-samples/navigation/automotive/github_build.gradle
+++ b/car/app/app-samples/navigation/automotive/github_build.gradle
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-apply plugin: 'com.android.application'
+plugins {
+    alias(libs.plugins.jetbrains.kotlin.android)
+    alias(libs.plugins.android.application)
+}
 
 android {
     compileSdk 34
@@ -39,14 +42,19 @@
         }
     }
 
-    compileOptions {
-        targetCompatibility = JavaVersion.VERSION_19
-        sourceCompatibility = JavaVersion.VERSION_19
+    java.toolchain {
+        languageVersion.set(JavaLanguageVersion.of(libs.versions.java.get()))
     }
+
+    kotlinOptions {
+        jvmTarget = libs.versions.java.get()
+    }
+
     namespace "androidx.car.app.sample.navigation"
 }
 
 dependencies {
-    implementation "androidx.car.app:app-automotive:1.4.0"
+    implementation libs.androidx.app.automotive
     implementation project(":navigation:common")
+    implementation libs.androidx.core.ktx
 }
diff --git a/car/app/app-samples/navigation/common/github_build.gradle b/car/app/app-samples/navigation/common/github_build.gradle
index 18d741d..2158a92 100644
--- a/car/app/app-samples/navigation/common/github_build.gradle
+++ b/car/app/app-samples/navigation/common/github_build.gradle
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-apply plugin: 'com.android.library'
+plugins {
+    alias(libs.plugins.jetbrains.kotlin.android)
+    alias(libs.plugins.android.library)
+}
 
 android {
     compileSdk 34
@@ -25,17 +28,22 @@
         versionCode 1
         versionName "1.0"
     }
-    compileOptions {
-        targetCompatibility = JavaVersion.VERSION_19
-        sourceCompatibility = JavaVersion.VERSION_19
+    java.toolchain {
+        languageVersion.set(JavaLanguageVersion.of(libs.versions.java.get()))
     }
+
+    kotlinOptions {
+        jvmTarget = libs.versions.java.get()
+    }
+
     namespace "androidx.car.app.sample.navigation.common"
 }
 
 dependencies {
-    implementation "androidx.constraintlayout:constraintlayout:2.1.4"
-    implementation "androidx.core:core:1.13.1"
+    implementation libs.androidx.constraintlayout
+    implementation libs.androidx.core
 
-    implementation "androidx.car.app:app:1.4.0"
-    implementation "androidx.annotation:annotation-experimental:1.4.1"
+    implementation libs.androidx.car.app
+    implementation libs.androidx.annotation.experimental
+    implementation libs.androidx.core.ktx
 }
diff --git a/car/app/app-samples/navigation/mobile/github_build.gradle b/car/app/app-samples/navigation/mobile/github_build.gradle
index 6a5c6d7..538be07 100644
--- a/car/app/app-samples/navigation/mobile/github_build.gradle
+++ b/car/app/app-samples/navigation/mobile/github_build.gradle
@@ -14,15 +14,18 @@
  * limitations under the License.
  */
 
-apply plugin: 'com.android.application'
+plugins {
+    alias(libs.plugins.jetbrains.kotlin.android)
+    alias(libs.plugins.android.application)
+}
 
 android {
-    compileSdk 33
+    compileSdk 34
 
     defaultConfig {
         applicationId "androidx.car.app.sample.navigation"
         minSdkVersion 23
-        targetSdkVersion 33
+        targetSdkVersion 34
         // Increment this to generate signed builds for uploading to Playstore
         // Make sure this is different from the navigation-automotive version
         versionCode 114
@@ -39,14 +42,19 @@
         }
     }
 
-    compileOptions {
-        targetCompatibility = JavaVersion.VERSION_1_8
-        sourceCompatibility = JavaVersion.VERSION_1_8
+    java.toolchain {
+        languageVersion.set(JavaLanguageVersion.of(libs.versions.java.get()))
     }
+
+    kotlinOptions {
+        jvmTarget = libs.versions.java.get()
+    }
+
     namespace "androidx.car.app.sample.navigation"
 }
 
 dependencies {
-    implementation "androidx.car.app:app-projected:1.3.0-beta01"
+    implementation libs.androidx.app.projected
     implementation project(":navigation:common")
+    implementation libs.androidx.core.ktx
 }
diff --git a/car/app/app-samples/showcase/automotive/github_build.gradle b/car/app/app-samples/showcase/automotive/github_build.gradle
index 8d7f075..1b7c192 100644
--- a/car/app/app-samples/showcase/automotive/github_build.gradle
+++ b/car/app/app-samples/showcase/automotive/github_build.gradle
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-apply plugin: 'com.android.application'
+plugins {
+    alias(libs.plugins.jetbrains.kotlin.android)
+    alias(libs.plugins.android.application)
+}
 
 android {
     compileSdk 34
@@ -39,9 +42,12 @@
         }
     }
 
-    compileOptions {
-        targetCompatibility = JavaVersion.VERSION_19
-        sourceCompatibility = JavaVersion.VERSION_19
+    java.toolchain {
+        languageVersion.set(JavaLanguageVersion.of(libs.versions.java.get()))
+    }
+
+    kotlinOptions {
+        jvmTarget = libs.versions.java.get()
     }
 
     testOptions.unitTests.includeAndroidResources true
@@ -49,6 +55,7 @@
 }
 
 dependencies {
-    implementation "androidx.car.app:app-automotive:1.4.0"
+    implementation libs.androidx.app.automotive
     implementation project(":showcase:common")
+    implementation libs.androidx.core.ktx
 }
diff --git a/car/app/app-samples/showcase/common/github_build.gradle b/car/app/app-samples/showcase/common/github_build.gradle
index 38f825f..cdf5eb5 100644
--- a/car/app/app-samples/showcase/common/github_build.gradle
+++ b/car/app/app-samples/showcase/common/github_build.gradle
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-apply plugin: 'com.android.library'
+plugins {
+    alias(libs.plugins.jetbrains.kotlin.android)
+    alias(libs.plugins.android.library)
+}
 
 android {
     compileSdk 34
@@ -26,15 +29,20 @@
         versionName "1.0"
     }
 
-    compileOptions {
-        targetCompatibility = JavaVersion.VERSION_19
-        sourceCompatibility = JavaVersion.VERSION_19
+    java.toolchain {
+        languageVersion.set(JavaLanguageVersion.of(libs.versions.java.get()))
     }
+
+    kotlinOptions {
+        jvmTarget = libs.versions.java.get()
+    }
+
     namespace "androidx.car.app.sample.showcase.common"
 }
 
 dependencies {
-    implementation "androidx.core:core:1.13.1"
-    implementation "androidx.car.app:app:1.4.0"
-    implementation "androidx.annotation:annotation-experimental:1.4.1"
+    implementation libs.androidx.core
+    implementation(libs.androidx.car.app)
+    implementation libs.androidx.annotation.experimental
+    implementation libs.androidx.core.ktx
 }
diff --git a/car/app/app-samples/showcase/mobile/github_build.gradle b/car/app/app-samples/showcase/mobile/github_build.gradle
index e92419a..f07c54f 100644
--- a/car/app/app-samples/showcase/mobile/github_build.gradle
+++ b/car/app/app-samples/showcase/mobile/github_build.gradle
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
-apply plugin: 'com.android.application'
+plugins {
+    alias(libs.plugins.jetbrains.kotlin.android)
+    alias(libs.plugins.android.application)
+}
 
 android {
     compileSdk 34
@@ -39,9 +42,12 @@
         }
     }
 
-    compileOptions {
-        targetCompatibility = JavaVersion.VERSION_19
-        sourceCompatibility = JavaVersion.VERSION_19
+    java.toolchain {
+        languageVersion.set(JavaLanguageVersion.of(libs.versions.java.get()))
+    }
+
+    kotlinOptions {
+        jvmTarget = libs.versions.java.get()
     }
 
     testOptions.unitTests.includeAndroidResources true
@@ -49,6 +55,7 @@
 }
 
 dependencies {
-    implementation "androidx.car.app:app-projected:1.4.0"
+    implementation libs.androidx.app.projected
     implementation project(":showcase:common")
+    implementation libs.androidx.core.ktx
 }