diff --git a/.github/workflows/dataconnect_demo_app.yml b/.github/workflows/dataconnect_demo_app.yml index 24a5434bd57..ccbc005ba1d 100644 --- a/.github/workflows/dataconnect_demo_app.yml +++ b/.github/workflows/dataconnect_demo_app.yml @@ -109,7 +109,7 @@ jobs: --no-daemon \ ${{ (inputs.gradleInfoLog && '--info') || '' }} \ --profile \ - -PdataConnect.minimalApp.firebaseCommand=${{ env.FDC_FIREBASE_COMMAND }} \ + -PdataConnect.demo.firebaseCommand=${{ env.FDC_FIREBASE_COMMAND }} \ assemble test - uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 diff --git a/firebase-dataconnect/demo/build.gradle.kts b/firebase-dataconnect/demo/build.gradle.kts index baad45dda7c..73204c49651 100644 --- a/firebase-dataconnect/demo/build.gradle.kts +++ b/firebase-dataconnect/demo/build.gradle.kts @@ -124,6 +124,11 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() { @get:Input @get:Optional abstract val nodeExecutableDirectory: Property + @get:InputFile + @get:Optional + @get:PathSensitive(PathSensitivity.ABSOLUTE) + abstract val dataConnectEmulatorExecutable: RegularFileProperty + @get:OutputDirectory abstract val outputDirectory: DirectoryProperty @get:Internal abstract val workDirectory: DirectoryProperty @@ -140,6 +145,7 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() { val firebaseToolsVersion: String = firebaseToolsVersion.get() val firebaseCommand: String = firebaseCommand.get() val nodeExecutableDirectory: String? = nodeExecutableDirectory.orNull + val dataConnectEmulatorExecutable: File? = dataConnectEmulatorExecutable.orNull?.asFile val outputDirectory: File = outputDirectory.get().asFile val workDirectory: File = workDirectory.get().asFile @@ -147,6 +153,7 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() { logger.info("firebaseToolsVersion: {}", firebaseToolsVersion) logger.info("firebaseCommand: {}", firebaseCommand) logger.info("nodeExecutableDirectory: {}", nodeExecutableDirectory) + logger.info("dataConnectEmulatorExecutable: {}", dataConnectEmulatorExecutable) logger.info("outputDirectory: {}", outputDirectory.absolutePath) logger.info("workDirectory: {}", workDirectory.absolutePath) @@ -170,6 +177,7 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() { this, firebaseCommand = firebaseCommand, nodeExecutableDirectory = nodeExecutableDirectory, + dataConnectEmulatorExecutable = dataConnectEmulatorExecutable, path = providerFactory.environmentVariable("PATH").orNull, ) args("--debug", "dataconnect:sdk:generate") @@ -197,6 +205,7 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() { execSpec: ExecSpec, firebaseCommand: String, nodeExecutableDirectory: String?, + dataConnectEmulatorExecutable: File?, path: String?, ) { execSpec.setCommandLine(firebaseCommand) @@ -215,6 +224,13 @@ abstract class DataConnectGenerateSourcesTask : DefaultTask() { if (newPath !== null) { execSpec.environment("PATH", newPath) } + + if (dataConnectEmulatorExecutable !== null) { + execSpec.environment( + "DATACONNECT_EMULATOR_BINARY_PATH", + dataConnectEmulatorExecutable.absolutePath, + ) + } } } } @@ -264,15 +280,18 @@ run { outputDirectory = layout.buildDirectory.dir("dataConnect/generatedSources") firebaseCommand = - project.providers - .gradleProperty("dataConnect.minimalApp.firebaseCommand") - .orElse("firebase") + project.providers.gradleProperty("dataConnect.demo.firebaseCommand").orElse("firebase") nodeExecutableDirectory = - project.providers.gradleProperty("dataConnect.minimalApp.nodeExecutableDirectory").map { + project.providers.gradleProperty("dataConnect.demo.nodeExecutableDirectory").map { projectDirectory.dir(it).asFile.absolutePath } + dataConnectEmulatorExecutable = + project.providers.gradleProperty("dataConnect.demo.dataConnectEmulatorExecutable").map { + projectDirectory.file(it) + } + val path = providers.environmentVariable("PATH") firebaseToolsVersion = providers @@ -281,6 +300,7 @@ run { this, firebaseCommand = firebaseCommand.get(), nodeExecutableDirectory = nodeExecutableDirectory.orNull, + dataConnectEmulatorExecutable = dataConnectEmulatorExecutable.orNull?.asFile, path = path.orNull, ) args("--version") diff --git a/firebase-dataconnect/demo/gradle.properties b/firebase-dataconnect/demo/gradle.properties index 12a9a7c6e9c..cab63a85bad 100644 --- a/firebase-dataconnect/demo/gradle.properties +++ b/firebase-dataconnect/demo/gradle.properties @@ -5,3 +5,21 @@ org.gradle.caching=true android.useAndroidX=true org.gradle.jvmargs=-Xmx2g + +// The path of the "firebase" command to use. +// If not specified, then "firebase" is used, resolved using the PATH environment variable. +// See build.gradle.kts for details. +//dataConnect.demo.firebaseCommand=/path/to/firebase + +// The path of the directory containing the "node" and "npm" commands. +// This directory will be prepended to the PATH before running the "firebase" command +// and may be useful to override the "node" and "npm" executables that get used by it. +// See build.gradle.kts for details. +//dataConnect.demo.nodeExecutableDirectory=/path/to/node/bin + +// The Data Connect emulator executable to use. +// If set, the `DATACONNECT_EMULATOR_BINARY_PATH` environment variable will be set before calling +// the "firebase" command to instruct it to use the specified Data Connect emulator rather than +// downloading an official version and using it. +// See build.gradle.kts for details. +//dataConnect.demo.dataConnectEmulatorExecutable=/path/to/cli