|
| 1 | +/* |
| 2 | + * Copyright 2026 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +plugins { |
| 18 | + alias(libs.plugins.android.application) |
| 19 | + alias(libs.plugins.kotlin.android) |
| 20 | + alias(libs.plugins.kotlin.compose) |
| 21 | + alias(libs.plugins.secrets.gradle.plugin) |
| 22 | + alias(libs.plugins.spotless) |
| 23 | +} |
| 24 | + |
| 25 | +configure<com.diffplug.gradle.spotless.SpotlessExtension> { |
| 26 | + kotlin { |
| 27 | + target("**/*.kt") |
| 28 | + ktlint().editorConfigOverride(mapOf("indent_size" to "4", "ktlint_function_naming_ignore_when_annotated_with" to "Composable")) |
| 29 | + trimTrailingWhitespace() |
| 30 | + endWithNewline() |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +android { |
| 35 | + namespace = "com.example.composedemos" |
| 36 | + compileSdk = libs.versions.compileSdk.get().toInt() |
| 37 | + |
| 38 | + defaultConfig { |
| 39 | + applicationId = "com.example.composedemos" |
| 40 | + minSdk = libs.versions.minSdk.get().toInt() |
| 41 | + targetSdk = libs.versions.targetSdk.get().toInt() |
| 42 | + versionCode = 1 |
| 43 | + versionName = "1.0" |
| 44 | + |
| 45 | + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" |
| 46 | + manifestPlaceholders["MAPS3D_API_KEY"] = "DEFAULT_API_KEY" |
| 47 | + vectorDrawables { |
| 48 | + useSupportLibrary = true |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + buildTypes { |
| 53 | + release { |
| 54 | + isMinifyEnabled = false |
| 55 | + proguardFiles( |
| 56 | + getDefaultProguardFile("proguard-android-optimize.txt"), |
| 57 | + "proguard-rules.pro" |
| 58 | + ) |
| 59 | + } |
| 60 | + } |
| 61 | + compileOptions { |
| 62 | + sourceCompatibility = JavaVersion.VERSION_11 |
| 63 | + targetCompatibility = JavaVersion.VERSION_11 |
| 64 | + } |
| 65 | + kotlin { |
| 66 | + compilerOptions { |
| 67 | + jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11) |
| 68 | + } |
| 69 | + } |
| 70 | + buildFeatures { |
| 71 | + compose = true |
| 72 | + buildConfig = true |
| 73 | + } |
| 74 | + packaging { |
| 75 | + resources { |
| 76 | + excludes += "/META-INF/{AL2.0,LGPL2.1}" |
| 77 | + } |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +dependencies { |
| 82 | + implementation(project(":maps3d-compose")) |
| 83 | + |
| 84 | + implementation(libs.androidx.core.ktx) |
| 85 | + implementation(libs.androidx.lifecycle.runtime.ktx) |
| 86 | + implementation(libs.androidx.activity.compose) |
| 87 | + |
| 88 | + implementation(platform(libs.androidx.compose.bom)) |
| 89 | + implementation(libs.androidx.ui) |
| 90 | + implementation(libs.androidx.ui.graphics) |
| 91 | + implementation(libs.androidx.ui.tooling.preview) |
| 92 | + implementation(libs.androidx.material3) |
| 93 | + |
| 94 | + // Maps 3D SDK |
| 95 | + implementation(libs.play.services.maps3d) |
| 96 | + implementation(libs.places) |
| 97 | + implementation(libs.androidx.fragment.ktx) |
| 98 | + |
| 99 | + // Maps Utils |
| 100 | + implementation(libs.maps.utils.ktx) |
| 101 | + |
| 102 | + // Material Icons Extended |
| 103 | + implementation(libs.androidx.material.icons.extended) |
| 104 | + |
| 105 | + // Lifecycle ViewModel Compose |
| 106 | + implementation("androidx.lifecycle:lifecycle-viewmodel-compose") |
| 107 | + |
| 108 | + testImplementation(libs.junit) |
| 109 | + testImplementation(libs.robolectric) |
| 110 | + androidTestImplementation(libs.androidx.junit) |
| 111 | + androidTestImplementation(libs.androidx.espresso.core) |
| 112 | + androidTestImplementation(platform(libs.androidx.compose.bom)) |
| 113 | + androidTestImplementation(libs.androidx.ui.test.junit4) |
| 114 | + androidTestImplementation(libs.androidx.uiautomator) |
| 115 | + androidTestImplementation(libs.kotlinx.serialization.json) |
| 116 | + androidTestImplementation(project(":visual-testing")) |
| 117 | + debugImplementation(libs.androidx.ui.tooling) |
| 118 | + debugImplementation(libs.androidx.ui.test.manifest) |
| 119 | +} |
| 120 | + |
| 121 | +secrets { |
| 122 | + // Only set propertiesFileName if the file exists to avoid FileNotFoundException in CI |
| 123 | + val secretsFile = rootProject.file("secrets.properties") |
| 124 | + if (secretsFile.exists()) { |
| 125 | + propertiesFileName = "secrets.properties" |
| 126 | + } |
| 127 | + defaultPropertiesFileName = "local.defaults.properties" |
| 128 | +} |
| 129 | + |
| 130 | +tasks.register<Exec>("installAndLaunch") { |
| 131 | + description = "Installs and launches the demo app." |
| 132 | + group = "install" |
| 133 | + dependsOn("installDebug") |
| 134 | + commandLine("adb", "shell", "am", "start", "-n", "com.example.composedemos/.MainActivity") |
| 135 | +} |
0 commit comments