Skip to content

Commit a0fc463

Browse files
committed
dataconnect: demo: build.gradle.kts: add ability to specify the Data Connect emulator executable to use.
1 parent 01694b4 commit a0fc463

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

firebase-dataconnect/demo/build.gradle.kts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
124124

125125
@get:Input @get:Optional abstract val nodeExecutableDirectory: Property<String>
126126

127+
@get:InputFile
128+
@get:Optional
129+
@get:PathSensitive(PathSensitivity.ABSOLUTE)
130+
abstract val dataConnectEmulatorExecutable: RegularFileProperty
131+
127132
@get:OutputDirectory abstract val outputDirectory: DirectoryProperty
128133

129134
@get:Internal abstract val workDirectory: DirectoryProperty
@@ -140,13 +145,15 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
140145
val firebaseToolsVersion: String = firebaseToolsVersion.get()
141146
val firebaseCommand: String = firebaseCommand.get()
142147
val nodeExecutableDirectory: String? = nodeExecutableDirectory.orNull
148+
val dataConnectEmulatorExecutable: File? = dataConnectEmulatorExecutable.orNull?.asFile
143149
val outputDirectory: File = outputDirectory.get().asFile
144150
val workDirectory: File = workDirectory.get().asFile
145151

146152
logger.info("inputDirectory: {}", inputDirectory.absolutePath)
147153
logger.info("firebaseToolsVersion: {}", firebaseToolsVersion)
148154
logger.info("firebaseCommand: {}", firebaseCommand)
149155
logger.info("nodeExecutableDirectory: {}", nodeExecutableDirectory)
156+
logger.info("dataConnectEmulatorExecutable: {}", dataConnectEmulatorExecutable)
150157
logger.info("outputDirectory: {}", outputDirectory.absolutePath)
151158
logger.info("workDirectory: {}", workDirectory.absolutePath)
152159

@@ -170,6 +177,7 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
170177
this,
171178
firebaseCommand = firebaseCommand,
172179
nodeExecutableDirectory = nodeExecutableDirectory,
180+
dataConnectEmulatorExecutable = dataConnectEmulatorExecutable,
173181
path = providerFactory.environmentVariable("PATH").orNull,
174182
)
175183
args("--debug", "dataconnect:sdk:generate")
@@ -197,6 +205,7 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
197205
execSpec: ExecSpec,
198206
firebaseCommand: String,
199207
nodeExecutableDirectory: String?,
208+
dataConnectEmulatorExecutable: File?,
200209
path: String?,
201210
) {
202211
execSpec.setCommandLine(firebaseCommand)
@@ -215,6 +224,10 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
215224
if (newPath !== null) {
216225
execSpec.environment("PATH", newPath)
217226
}
227+
228+
if (dataConnectEmulatorExecutable !== null) {
229+
execSpec.environment("DATACONNECT_EMULATOR_BINARY_PATH", dataConnectEmulatorExecutable)
230+
}
218231
}
219232
}
220233
}
@@ -265,14 +278,19 @@ run {
265278

266279
firebaseCommand =
267280
project.providers
268-
.gradleProperty("dataConnect.minimalApp.firebaseCommand")
281+
.gradleProperty("dataConnect.demo.firebaseCommand")
269282
.orElse("firebase")
270283

271284
nodeExecutableDirectory =
272-
project.providers.gradleProperty("dataConnect.minimalApp.nodeExecutableDirectory").map {
285+
project.providers.gradleProperty("dataConnect.demo.nodeExecutableDirectory").map {
273286
projectDirectory.dir(it).asFile.absolutePath
274287
}
275288

289+
dataConnectEmulatorExecutable =
290+
project.providers
291+
.gradleProperty("dataConnect.demo.dataConnectEmulatorExecutable")
292+
.map { projectDirectory.file(it) }
293+
276294
val path = providers.environmentVariable("PATH")
277295
firebaseToolsVersion =
278296
providers
@@ -281,6 +299,7 @@ run {
281299
this,
282300
firebaseCommand = firebaseCommand.get(),
283301
nodeExecutableDirectory = nodeExecutableDirectory.orNull,
302+
dataConnectEmulatorExecutable = dataConnectEmulatorExecutable.orNull?.asFile,
284303
path = path.orNull,
285304
)
286305
args("--version")

firebase-dataconnect/demo/gradle.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,21 @@ org.gradle.caching=true
55
android.useAndroidX=true
66

77
org.gradle.jvmargs=-Xmx2g
8+
9+
// The path of the "firebase" command to use.
10+
// If not specified, then "firebase" is used, resolved using the PATH environment variable.
11+
// See build.gradle.kts for details.
12+
//dataConnect.demo.firebaseCommand=/path/to/firebase
13+
14+
// The path of the directory containing the "node" and "npm" commands.
15+
// This directory will be prepended to the PATH before running the "firebase" command
16+
// and may be useful to override the "node" and "npm" executables that get used by it.
17+
// See build.gradle.kts for details.
18+
//dataConnect.demo.nodeExecutableDirectory=/path/to/node/bin
19+
20+
// The Data Connect emulator executable to use.
21+
// If set, the `DATACONNECT_EMULATOR_BINARY_PATH` environment variable will be set before calling
22+
// the "firebase" command to instruct it to use the specified Data Connect emulator rather than
23+
// downloading an official version and using it.
24+
// See build.gradle.kts for details.
25+
//dataConnect.demo.dataConnectEmulatorExecutable=/path/to/cli

0 commit comments

Comments
 (0)