Skip to content

Commit a7d26f5

Browse files
authored
dataconnect: demo: add support for fdc emulator "preview flags" and update dependencies (#7160)
1 parent 691e9c8 commit a7d26f5

File tree

2 files changed

+36
-32
lines changed

2 files changed

+36
-32
lines changed

firebase-dataconnect/demo/build.gradle.kts

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,35 @@ import java.nio.charset.StandardCharsets
1919

2020
plugins {
2121
// Use whichever versions of these dependencies suit your application.
22-
// The versions shown here were the latest versions as of June 10, 2025.
22+
// The versions shown here were the latest versions as of July 17, 2025.
2323
// Note, however, that the version of kotlin("plugin.serialization") _must_,
2424
// in general, match the version of kotlin("android").
25-
id("com.android.application") version "8.11.0"
26-
id("com.google.gms.google-services") version "4.4.2"
25+
id("com.android.application") version "8.11.1"
26+
id("com.google.gms.google-services") version "4.4.3"
2727
val kotlinVersion = "2.1.10"
2828
kotlin("android") version kotlinVersion
2929
kotlin("plugin.serialization") version kotlinVersion
3030

3131
// The following code in this "plugins" block can be omitted from customer
3232
// facing documentation as it is an implementation detail of this application.
33-
id("com.diffplug.spotless") version "7.0.0.BETA4"
33+
id("com.diffplug.spotless") version "7.1.0"
3434

3535
id("org.jetbrains.dokka") version "2.0.0"
3636
}
3737

3838
dependencies {
3939
// Use whichever versions of these dependencies suit your application.
40-
// The versions shown here were the latest versions as of June 10, 2025.
40+
// The versions shown here were the latest versions as of July 17, 2025.
4141

4242
// Data Connect
43-
implementation(platform("com.google.firebase:firebase-bom:33.15.0"))
43+
implementation(platform("com.google.firebase:firebase-bom:33.16.0"))
4444
implementation("com.google.firebase:firebase-dataconnect")
45-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
46-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.1")
47-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.8.1")
45+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
46+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
47+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.9.0")
4848
implementation("androidx.appcompat:appcompat:1.7.1")
4949
implementation("androidx.activity:activity-ktx:1.10.1")
50-
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.1")
50+
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.2")
5151
implementation("com.google.android.material:material:1.12.0")
5252

5353
// The following code in this "dependencies" block can be omitted from customer
@@ -70,10 +70,10 @@ dokka {
7070

7171
android {
7272
namespace = "com.google.firebase.dataconnect.minimaldemo"
73-
compileSdk = 35
73+
compileSdk = 36
7474
defaultConfig {
7575
minSdk = 23
76-
targetSdk = 35
76+
targetSdk = 36
7777
versionCode = 1
7878
versionName = "1.0"
7979
}
@@ -138,6 +138,8 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
138138
@get:PathSensitive(PathSensitivity.ABSOLUTE)
139139
abstract val dataConnectEmulatorExecutable: RegularFileProperty
140140

141+
@get:Input @get:Optional abstract val dataConnectPreviewFlags: Property<String>
142+
141143
@get:OutputDirectory abstract val outputDirectory: DirectoryProperty
142144

143145
@get:Internal abstract val workDirectory: DirectoryProperty
@@ -155,6 +157,7 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
155157
val firebaseCommand: String = firebaseCommand.get()
156158
val nodeExecutableDirectory: String? = nodeExecutableDirectory.orNull
157159
val dataConnectEmulatorExecutable: File? = dataConnectEmulatorExecutable.orNull?.asFile
160+
val dataConnectPreviewFlags: String? = dataConnectPreviewFlags.orNull
158161
val outputDirectory: File = outputDirectory.get().asFile
159162
val workDirectory: File = workDirectory.get().asFile
160163

@@ -163,6 +166,7 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
163166
logger.info("firebaseCommand: {}", firebaseCommand)
164167
logger.info("nodeExecutableDirectory: {}", nodeExecutableDirectory)
165168
logger.info("dataConnectEmulatorExecutable: {}", dataConnectEmulatorExecutable)
169+
logger.info("dataConnectPreviewFlags: {}", dataConnectPreviewFlags)
166170
logger.info("outputDirectory: {}", outputDirectory.absolutePath)
167171
logger.info("workDirectory: {}", workDirectory.absolutePath)
168172

@@ -187,14 +191,15 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
187191
firebaseCommand = firebaseCommand,
188192
nodeExecutableDirectory = nodeExecutableDirectory,
189193
dataConnectEmulatorExecutable = dataConnectEmulatorExecutable,
194+
dataConnectPreviewFlags = dataConnectPreviewFlags,
190195
path = providerFactory.environmentVariable("PATH").orNull,
191196
)
192197
args("--debug", "dataconnect:sdk:generate")
193198
workingDir(inputDirectory)
194199
isIgnoreExitValue = false
195-
if (logStream !== null) {
196-
standardOutput = logStream
197-
errorOutput = logStream
200+
logStream?.let {
201+
standardOutput = it
202+
errorOutput = it
198203
}
199204
}
200205
}
@@ -215,31 +220,21 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
215220
firebaseCommand: String,
216221
nodeExecutableDirectory: String?,
217222
dataConnectEmulatorExecutable: File?,
223+
dataConnectPreviewFlags: String?,
218224
path: String?,
219225
) {
220226
execSpec.setCommandLine(firebaseCommand)
221227

222-
val newPath: String? =
223-
if (nodeExecutableDirectory === null) {
224-
null
225-
} else {
226-
if (path === null) {
227-
nodeExecutableDirectory
228-
} else {
229-
nodeExecutableDirectory + File.pathSeparator + path
230-
}
231-
}
232-
233-
if (newPath !== null) {
228+
nodeExecutableDirectory?.let {
229+
val newPath = if (path === null) it else (it + File.pathSeparator + path)
234230
execSpec.environment("PATH", newPath)
235231
}
236232

237-
if (dataConnectEmulatorExecutable !== null) {
238-
execSpec.environment(
239-
"DATACONNECT_EMULATOR_BINARY_PATH",
240-
dataConnectEmulatorExecutable.absolutePath,
241-
)
233+
dataConnectEmulatorExecutable?.let {
234+
execSpec.environment("DATACONNECT_EMULATOR_BINARY_PATH", it.absolutePath)
242235
}
236+
237+
dataConnectPreviewFlags?.let { execSpec.environment("DATA_CONNECT_PREVIEW", it) }
243238
}
244239
}
245240
}
@@ -301,6 +296,9 @@ run {
301296
projectDirectory.file(it)
302297
}
303298

299+
dataConnectPreviewFlags =
300+
project.providers.gradleProperty("dataConnect.demo.dataConnectPreviewFlags")
301+
304302
val path = providers.environmentVariable("PATH")
305303
firebaseToolsVersion =
306304
providers
@@ -310,6 +308,7 @@ run {
310308
firebaseCommand = firebaseCommand.get(),
311309
nodeExecutableDirectory = nodeExecutableDirectory.orNull,
312310
dataConnectEmulatorExecutable = dataConnectEmulatorExecutable.orNull?.asFile,
311+
dataConnectPreviewFlags = dataConnectPreviewFlags.orNull,
313312
path = path.orNull,
314313
)
315314
args("--version")

firebase-dataconnect/demo/gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
2929
// downloading an official version and using it.
3030
// See build.gradle.kts for details.
3131
//dataConnect.demo.dataConnectEmulatorExecutable=/path/to/cli
32+
33+
// A comma-separated list of "preview flags" to specify to the Data Connect emulator and codegen.
34+
// This is used to enable features that are not (yet) intended for end-user consumption.
35+
// See build.gradle.kts for details.
36+
//dataConnect.demo.dataConnectPreviewFlags=flag1,flag2,flag3

0 commit comments

Comments
 (0)