@@ -16,12 +16,21 @@ abstract class InstallFirebaseToolsTask : DefaultTask() {
1616
1717 @get:OutputDirectory abstract val destDir: DirectoryProperty
1818
19+ @get:OutputFile abstract val firebaseExecutable: RegularFileProperty
20+
1921 @get:Inject abstract val execOperations: ExecOperations
2022
23+ fun initializeProperties (version : Provider <String >, destDir : Provider <Directory >) {
24+ this .version.set(version)
25+ this .destDir.set(destDir)
26+ this .firebaseExecutable.set(destDir.map { it.dir(" node_modules" ).dir(" .bin" ).file(" firebase" ) })
27+ }
28+
2129 @TaskAction
2230 fun execute () {
2331 val destDir: File = destDir.get().asFile
2432 val version: String = version.get()
33+ val firebaseExecutable: File = firebaseExecutable.get().asFile
2534
2635 val packageJsonFile = File (destDir, " package.json" )
2736 logger.lifecycle(" Creating $packageJsonFile " )
@@ -40,26 +49,35 @@ abstract class InstallFirebaseToolsTask : DefaultTask() {
4049 )
4150 logger.lifecycle(" Running command in directory $workingDir : ${commandLine.joinToString(" " )} " )
4251 }
52+
53+ execOperations.exec {
54+ setCommandLine(firebaseExecutable.path, " --version" )
55+ logger.lifecycle(
56+ " Running command to verify successful installation: ${commandLine.joinToString(" " )} "
57+ )
58+ }
4359 }
4460}
4561
46- val installFirebaseToolsTask = tasks.register<InstallFirebaseToolsTask >(" installFirebaseTools" ) {
47- group = " Data Connect CI"
48- description = " Install the firebase-tools npm package"
49- destDir.set(layout.buildDirectory.dir(" firebase-tools" ))
50- version.set(providers.requiredGradleProperty(" firebaseToolsVersion" ))
51- }
62+ val installFirebaseToolsTask =
63+ tasks.register<InstallFirebaseToolsTask >(" installFirebaseTools" ) {
64+ group = " Data Connect CI"
65+ description = " Install the firebase-tools npm package"
66+ initializeProperties(
67+ version = providers.requiredGradleProperty(" firebaseToolsVersion" ),
68+ destDir = layout.buildDirectory.dir(" firebase-tools" ),
69+ )
70+ }
5271
5372fun ProviderFactory.requiredGradleProperty (propertyName : String ) =
5473 gradleProperty(propertyName)
5574 .orElse(
5675 providers.provider<Nothing > {
5776 throw RequiredPropertyMissing (
58- " zzyzx=${project.property(propertyName)} Project property \" $propertyName \" was not set, " +
59- " but is required. " +
60- " Consider setting this project property by specifying " +
61- " -P$propertyName =<value> on the Gradle command line, " +
62- " or by setting the ORG_GRADLE_PROJECT_installFirebaseTools environment variable."
77+ " Required project property \" $propertyName \" was not set; " +
78+ " consider setting it " +
79+ " by specifying -P$propertyName =<value> on the Gradle command line " +
80+ " or by setting the environment variable ORG_GRADLE_PROJECT_$propertyName "
6381 )
6482 }
6583 )
0 commit comments