Skip to content

Commit 614a072

Browse files
committed
Create Auto sample module
1 parent dc4ab79 commit 614a072

File tree

7 files changed

+142
-1
lines changed

7 files changed

+142
-1
lines changed

buildSrc/src/main/kotlin/com/datadog/gradle/config/AndroidConfig.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ object AndroidConfig {
1818
const val TARGET_SDK = 36
1919
const val MIN_SDK = 21
2020
const val MIN_SDK_FOR_WEAR_AND_TV = 23
21+
const val MIN_SDK_FOR_AUTO = 29
2122
const val BUILD_TOOLS_VERSION = "36.0.0"
2223

2324
val VERSION = Version(2, 23, 0, Version.Type.Snapshot)

buildSrc/src/main/kotlin/com/datadog/gradle/config/FlavorBuildConfig.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,20 @@ fun ApplicationDefaultConfig.configureFlavorForTvApp(
122122
"\"${config.token}\""
123123
)
124124
}
125+
126+
@Suppress("UnstableApiUsage")
127+
fun ApplicationDefaultConfig.configureFlavorForAutoApp(
128+
rootDir: File
129+
) {
130+
val config = sampleAppConfig("${rootDir.absolutePath}/config/auto.json")
131+
buildConfigField(
132+
"String",
133+
"DD_RUM_APPLICATION_ID",
134+
"\"${config.rumApplicationId}\""
135+
)
136+
buildConfigField(
137+
"String",
138+
"DD_CLIENT_TOKEN",
139+
"\"${config.token}\""
140+
)
141+
}

gradle/libs.versions.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ androidDesugaringSdk = "2.0.4"
1313
androidToolsPlugin = "8.9.1"
1414
androidXAnnotations = "1.9.1"
1515
androidXAppCompat = "1.4.2" # Next version will bring coroutines
16+
androidXCar = "1.4.0"
1617
androidXCollection = "1.4.5"
1718
androidXComposeBom = "2023.10.01" # Next version will bring coroutines
1819
androidXComposeCompilerExtension = "1.5.14"
@@ -23,6 +24,7 @@ androidXCore = "1.3.1"
2324
androidXFragment = "1.2.4"
2425
androidXLeanback = "1.0.0"
2526
androidXLifecycle = "2.8.7"
27+
androidXLegacy = "1.0.0"
2628
androidXMetrics = "1.0.0-beta02"
2729
androidXMultidex = "2.0.1"
2830
androidXNavigation = "2.7.7"
@@ -106,7 +108,6 @@ openTelemetryBenchmark = "1.40.0"
106108
re2j = "1.7"
107109
material3Android = "1.1.2"
108110

109-
110111
[libraries]
111112

112113
# Classpaths
@@ -141,6 +142,9 @@ adapterDelegatesViewBinding = { module = "com.hannesdorfmann:adapterdelegates4-k
141142
androidDesugaringSdk = { module = "com.android.tools:desugar_jdk_libs", version.ref = "androidDesugaringSdk" }
142143
androidXAnnotation = { module = "androidx.annotation:annotation", version.ref = "androidXAnnotations" }
143144
androidXAppCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidXAppCompat" }
145+
androidXCarApp = { module = "androidx.car.app:app", version.ref = "androidXCar" }
146+
androidXCarAutomotive = { module = "androidx.car.app:app-automotive", version.ref = "androidXCar" }
147+
androidXCarProjected = { module = "androidx.car.app:app-projected", version.ref = "androidXCar" }
144148
androidXCollection = { module = "androidx.collection:collection", version.ref = "androidXCollection" }
145149
androidXConstraintLayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidXConstraintLayout" }
146150
androidXCore = { module = "androidx.core:core", version.ref = "androidXCore" }
@@ -157,6 +161,8 @@ androidXWorkManager = { module = "androidx.work:work-runtime", version.ref = "an
157161
androidXLifecycleCompose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidXLifecycle" }
158162
androidXLifecycleLiveDataKtx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "androidXLifecycle" }
159163
androidXLifecycleViewModelKtx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidXLifecycle" }
164+
androidXLegacySupportV4 = { group = "androidx.legacy", name = "legacy-support-v4", version.ref = "androidXLegacy" }
165+
androidXLegacySupportV13 = { group = "androidx.legacy", name = "legacy-support-v13", version.ref = "androidXLegacy" }
160166
daggerLib = { module = "com.google.dagger:dagger", version.ref = "dagger" }
161167
daggerCompiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" }
162168
googleAccompanistAppCompatTheme = { module = "com.google.accompanist:accompanist-appcompat-theme", version.ref = "googleAccompanist" }

sample/automotive/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

sample/automotive/build.gradle.kts

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import com.datadog.gradle.config.AndroidConfig
2+
import com.datadog.gradle.config.configureFlavorForAutoApp
3+
import com.datadog.gradle.config.configureFlavorForTvApp
4+
import com.datadog.gradle.config.dependencyUpdateConfig
5+
import com.datadog.gradle.config.java17
6+
import com.datadog.gradle.config.junitConfig
7+
import com.datadog.gradle.config.kotlinConfig
8+
import com.datadog.gradle.config.taskConfig
9+
10+
plugins {
11+
id("com.android.application")
12+
kotlin("android")
13+
id("com.github.ben-manes.versions")
14+
alias(libs.plugins.datadogGradlePlugin)
15+
}
16+
17+
android {
18+
compileSdk = AndroidConfig.TARGET_SDK
19+
buildToolsVersion = AndroidConfig.BUILD_TOOLS_VERSION
20+
21+
defaultConfig {
22+
minSdk = AndroidConfig.MIN_SDK_FOR_AUTO
23+
targetSdk = AndroidConfig.TARGET_SDK
24+
versionCode = AndroidConfig.VERSION.code
25+
versionName = AndroidConfig.VERSION.name
26+
multiDexEnabled = true
27+
28+
buildFeatures {
29+
buildConfig = true
30+
}
31+
32+
configureFlavorForAutoApp(project.rootDir)
33+
}
34+
35+
namespace = "com.datadog.sample.automotive"
36+
37+
compileOptions {
38+
isCoreLibraryDesugaringEnabled = true
39+
java17()
40+
}
41+
42+
testOptions {
43+
unitTests.isReturnDefaultValues = true
44+
}
45+
46+
buildTypes {
47+
getByName("debug") {
48+
isMinifyEnabled = false
49+
}
50+
51+
getByName("release") {
52+
proguardFiles(
53+
getDefaultProguardFile("proguard-android-optimize.txt"),
54+
"proguard-rules.pro"
55+
)
56+
isMinifyEnabled = false
57+
}
58+
}
59+
}
60+
61+
dependencies {
62+
// Datadog Libraries
63+
implementation(project(":features:dd-sdk-android-logs"))
64+
implementation(project(":features:dd-sdk-android-rum"))
65+
implementation(project(":integrations:dd-sdk-android-okhttp"))
66+
implementation(project(":integrations:dd-sdk-android-okhttp-otel"))
67+
68+
// Desugaring SDK
69+
coreLibraryDesugaring(libs.androidDesugaringSdk)
70+
71+
implementation(libs.kotlin)
72+
73+
// Android dependencies
74+
implementation(libs.androidXMultidex)
75+
implementation(libs.androidXCoreKtx)
76+
implementation(libs.androidXAppCompat)
77+
implementation(libs.androidXLegacySupportV4)
78+
implementation(libs.androidXLegacySupportV13)
79+
80+
// Android Car
81+
implementation(libs.androidXCarApp)
82+
implementation(libs.androidXCarAutomotive)
83+
}
84+
85+
kotlinConfig(evaluateWarningsAsErrors = false)
86+
taskConfig<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
87+
compilerOptions {
88+
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
89+
}
90+
}
91+
junitConfig()
92+
dependencyUpdateConfig()
93+
94+

sample/automotive/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ include(":sample:tv")
5555
include(":sample:wear")
5656
include(":sample:vendor-lib")
5757
include(":sample:benchmark")
58+
include(":sample:automotive")
5859

5960
// TOOLCHAIN
6061
include(":tools:detekt")

0 commit comments

Comments
 (0)