Skip to content

Commit 9b510c4

Browse files
authored
dataconnect: demo: build.gradle.kts: add ability to specify the Data Connect emulator executable to use (#7032)
1 parent 78b278e commit 9b510c4

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

.github/workflows/dataconnect_demo_app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
--no-daemon \
110110
${{ (inputs.gradleInfoLog && '--info') || '' }} \
111111
--profile \
112-
-PdataConnect.minimalApp.firebaseCommand=${{ env.FDC_FIREBASE_COMMAND }} \
112+
-PdataConnect.demo.firebaseCommand=${{ env.FDC_FIREBASE_COMMAND }} \
113113
assemble test
114114
115115
- uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1

firebase-dataconnect/demo/build.gradle.kts

Lines changed: 24 additions & 4 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,13 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() {
215224
if (newPath !== null) {
216225
execSpec.environment("PATH", newPath)
217226
}
227+
228+
if (dataConnectEmulatorExecutable !== null) {
229+
execSpec.environment(
230+
"DATACONNECT_EMULATOR_BINARY_PATH",
231+
dataConnectEmulatorExecutable.absolutePath,
232+
)
233+
}
218234
}
219235
}
220236
}
@@ -264,15 +280,18 @@ run {
264280
outputDirectory = layout.buildDirectory.dir("dataConnect/generatedSources")
265281

266282
firebaseCommand =
267-
project.providers
268-
.gradleProperty("dataConnect.minimalApp.firebaseCommand")
269-
.orElse("firebase")
283+
project.providers.gradleProperty("dataConnect.demo.firebaseCommand").orElse("firebase")
270284

271285
nodeExecutableDirectory =
272-
project.providers.gradleProperty("dataConnect.minimalApp.nodeExecutableDirectory").map {
286+
project.providers.gradleProperty("dataConnect.demo.nodeExecutableDirectory").map {
273287
projectDirectory.dir(it).asFile.absolutePath
274288
}
275289

290+
dataConnectEmulatorExecutable =
291+
project.providers.gradleProperty("dataConnect.demo.dataConnectEmulatorExecutable").map {
292+
projectDirectory.file(it)
293+
}
294+
276295
val path = providers.environmentVariable("PATH")
277296
firebaseToolsVersion =
278297
providers
@@ -281,6 +300,7 @@ run {
281300
this,
282301
firebaseCommand = firebaseCommand.get(),
283302
nodeExecutableDirectory = nodeExecutableDirectory.orNull,
303+
dataConnectEmulatorExecutable = dataConnectEmulatorExecutable.orNull?.asFile,
284304
path = path.orNull,
285305
)
286306
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)