Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 31 additions & 32 deletions firebase-dataconnect/demo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,35 @@ import java.nio.charset.StandardCharsets

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

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

id("org.jetbrains.dokka") version "2.0.0"
}

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

// Data Connect
implementation(platform("com.google.firebase:firebase-bom:33.15.0"))
implementation(platform("com.google.firebase:firebase-bom:33.16.0"))
implementation("com.google.firebase:firebase-dataconnect")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.8.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.9.0")
implementation("androidx.appcompat:appcompat:1.7.1")
implementation("androidx.activity:activity-ktx:1.10.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.2")
implementation("com.google.android.material:material:1.12.0")

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

android {
namespace = "com.google.firebase.dataconnect.minimaldemo"
compileSdk = 35
compileSdk = 36
defaultConfig {
minSdk = 23
targetSdk = 35
targetSdk = 36
versionCode = 1
versionName = "1.0"
}
Expand Down Expand Up @@ -138,6 +138,8 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
@get:PathSensitive(PathSensitivity.ABSOLUTE)
abstract val dataConnectEmulatorExecutable: RegularFileProperty

@get:Input @get:Optional abstract val dataConnectPreviewFlags: Property<String>

@get:OutputDirectory abstract val outputDirectory: DirectoryProperty

@get:Internal abstract val workDirectory: DirectoryProperty
Expand All @@ -155,6 +157,7 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
val firebaseCommand: String = firebaseCommand.get()
val nodeExecutableDirectory: String? = nodeExecutableDirectory.orNull
val dataConnectEmulatorExecutable: File? = dataConnectEmulatorExecutable.orNull?.asFile
val dataConnectPreviewFlags: String? = dataConnectPreviewFlags.orNull
val outputDirectory: File = outputDirectory.get().asFile
val workDirectory: File = workDirectory.get().asFile

Expand All @@ -163,6 +166,7 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
logger.info("firebaseCommand: {}", firebaseCommand)
logger.info("nodeExecutableDirectory: {}", nodeExecutableDirectory)
logger.info("dataConnectEmulatorExecutable: {}", dataConnectEmulatorExecutable)
logger.info("dataConnectPreviewFlags: {}", dataConnectPreviewFlags)
logger.info("outputDirectory: {}", outputDirectory.absolutePath)
logger.info("workDirectory: {}", workDirectory.absolutePath)

Expand All @@ -187,14 +191,15 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
firebaseCommand = firebaseCommand,
nodeExecutableDirectory = nodeExecutableDirectory,
dataConnectEmulatorExecutable = dataConnectEmulatorExecutable,
dataConnectPreviewFlags = dataConnectPreviewFlags,
path = providerFactory.environmentVariable("PATH").orNull,
)
args("--debug", "dataconnect:sdk:generate")
workingDir(inputDirectory)
isIgnoreExitValue = false
if (logStream !== null) {
standardOutput = logStream
errorOutput = logStream
logStream?.let {
standardOutput = it
errorOutput = it
}
}
}
Expand All @@ -215,31 +220,21 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
firebaseCommand: String,
nodeExecutableDirectory: String?,
dataConnectEmulatorExecutable: File?,
dataConnectPreviewFlags: String?,
path: String?,
) {
execSpec.setCommandLine(firebaseCommand)

val newPath: String? =
if (nodeExecutableDirectory === null) {
null
} else {
if (path === null) {
nodeExecutableDirectory
} else {
nodeExecutableDirectory + File.pathSeparator + path
}
}

if (newPath !== null) {
nodeExecutableDirectory?.let {
val newPath = if (path === null) it else (it + File.pathSeparator + path)
execSpec.environment("PATH", newPath)
}

if (dataConnectEmulatorExecutable !== null) {
execSpec.environment(
"DATACONNECT_EMULATOR_BINARY_PATH",
dataConnectEmulatorExecutable.absolutePath,
)
dataConnectEmulatorExecutable?.let {
execSpec.environment("DATACONNECT_EMULATOR_BINARY_PATH", it.absolutePath)
}

dataConnectPreviewFlags?.let { execSpec.environment("DATA_CONNECT_PREVIEW", it) }
}
}
}
Expand Down Expand Up @@ -301,6 +296,9 @@ run {
projectDirectory.file(it)
}

dataConnectPreviewFlags =
project.providers.gradleProperty("dataConnect.demo.dataConnectPreviewFlags")

val path = providers.environmentVariable("PATH")
firebaseToolsVersion =
providers
Expand All @@ -310,6 +308,7 @@ run {
firebaseCommand = firebaseCommand.get(),
nodeExecutableDirectory = nodeExecutableDirectory.orNull,
dataConnectEmulatorExecutable = dataConnectEmulatorExecutable.orNull?.asFile,
dataConnectPreviewFlags = dataConnectPreviewFlags.orNull,
path = path.orNull,
)
args("--version")
Expand Down
5 changes: 5 additions & 0 deletions firebase-dataconnect/demo/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
// downloading an official version and using it.
// See build.gradle.kts for details.
//dataConnect.demo.dataConnectEmulatorExecutable=/path/to/cli

// A comma-separated list of "preview flags" to specify to the Data Connect emulator and codegen.
// This is used to enable features that are not (yet) intended for end-user consumption.
// See build.gradle.kts for details.
//dataConnect.demo.dataConnectPreviewFlags=flag1,flag2,flag3
Loading