From ff8fbc5a2a85d1b43758367f6468220dac359a9b Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Fri, 1 Nov 2024 20:07:21 +0000 Subject: [PATCH 1/2] connectors.gradle.kts: fix unwarranted error from updateJson task during configure time --- .../connectors/connectors.gradle.kts | 65 ++++++++++++++++--- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/firebase-dataconnect/connectors/connectors.gradle.kts b/firebase-dataconnect/connectors/connectors.gradle.kts index 7180bec35ad..5f4d5e7cc66 100644 --- a/firebase-dataconnect/connectors/connectors.gradle.kts +++ b/firebase-dataconnect/connectors/connectors.gradle.kts @@ -125,34 +125,81 @@ tasks.register("updateJson") { jsonFile.set( project.layout.projectDirectory.file( "../gradleplugin/plugin/src/main/resources/com/google/firebase/dataconnect/gradle/" + - "plugin/DataConnectExecutableVersions.json" + "plugin/DataConnectExecutableVersions.json" ) ) workDirectory.set(project.layout.buildDirectory.dir("updateJson")) - val singleVersion: String? = project.providers.gradleProperty("version").orNull + val propertyNames = object { + val version = "version" + val versions = "versions" + val updateMode = "updateMode" + val defaultVersion = "defaultVersion" + } + + val singleVersion: String? = project.providers.gradleProperty(propertyNames.version).orNull val multipleVersions: List? = - project.providers.gradleProperty("versions").orNull?.split(',') + project.providers.gradleProperty(propertyNames.versions).orNull?.split(',') versions.set( buildList { singleVersion?.let { add(it) } multipleVersions?.let { addAll(it) } - if (isEmpty()) { - throw Exception("bm6d5ezxzd 'version' or 'versions' property must be specified") - } } ) + doFirst { + if (versions.get().isEmpty()) { + logger.warn( + "WARNING: no '${propertyNames.version}' or '${propertyNames.versions}' specified " + + "for task '$name'; no versions will be added to ${jsonFile.get()}. " + + "Try specifying something like '-P${propertyNames.version}=1.2.3' or " + + "'-P${propertyNames.versions}=1.2.3,4.5.6' on the gradle command line " + + "if you want to add versions (warning code bm6d5ezxzd)" + ) + } + } + updateMode.set( - project.providers.gradleProperty("updateMode").map { + project.providers.gradleProperty(propertyNames.updateMode).map { when (it) { "overwrite" -> UpdateDataConnectExecutableVersionsTask.UpdateMode.Overwrite "update" -> UpdateDataConnectExecutableVersionsTask.UpdateMode.Update else -> - throw Exception("ahe4zadcjs 'updateMode' must be 'overwrite' or 'update', but got: $it") + throw Exception( + "Invalid '${propertyNames.updateMode}' specified for task '$name': $it. " + + "Valid values are 'update' and 'overwrite'. " + + "Try specifying '-P${propertyNames.updateMode}=update' or " + + "'-P${propertyNames.updateMode}=overwrite' on the gradle command line. " + + "(error code v2e3cfqbnf)" + ) } } ) - defaultVersion.set(project.providers.gradleProperty("defaultVersion")) + doFirst { + if (!updateMode.isPresent) { + logger.warn( + "WARNING: no '${propertyNames.updateMode}' specified for task '$name'; " + + "the default update mode of 'update' will be used when updating ${jsonFile.get()}. " + + "Try specifying '-P${propertyNames.updateMode}=update' or " + + "'-P${propertyNames.updateMode}=overwrite' on the gradle command line " + + "if you want a different update mode, or just want to be explicit about " + + "which update mode is in effect (warning code tjyscqmdne)" + ) + } + } + + defaultVersion.set(project.providers.gradleProperty(propertyNames.defaultVersion)) + + doFirst { + if (!defaultVersion.isPresent) { + logger.warn( + "WARNING: no '${propertyNames.defaultVersion}' specified for task '$name'; " + + "the default version will not be updated in ${jsonFile.get()}. " + + "Try specifying something like '-P${propertyNames.defaultVersion}=1.2.3' " + + "on the gradle command line if you want to update the default version " + + "(warning code vqrbrktx9f)" + ) + } + } } From 4c5b35287ac0441288ef84fd139fde7fb61c0e2e Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Fri, 1 Nov 2024 20:28:16 +0000 Subject: [PATCH 2/2] spotlessApply --- .../connectors/connectors.gradle.kts | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/firebase-dataconnect/connectors/connectors.gradle.kts b/firebase-dataconnect/connectors/connectors.gradle.kts index 5f4d5e7cc66..3a0282896d3 100644 --- a/firebase-dataconnect/connectors/connectors.gradle.kts +++ b/firebase-dataconnect/connectors/connectors.gradle.kts @@ -125,17 +125,18 @@ tasks.register("updateJson") { jsonFile.set( project.layout.projectDirectory.file( "../gradleplugin/plugin/src/main/resources/com/google/firebase/dataconnect/gradle/" + - "plugin/DataConnectExecutableVersions.json" + "plugin/DataConnectExecutableVersions.json" ) ) workDirectory.set(project.layout.buildDirectory.dir("updateJson")) - val propertyNames = object { - val version = "version" - val versions = "versions" - val updateMode = "updateMode" - val defaultVersion = "defaultVersion" - } + val propertyNames = + object { + val version = "version" + val versions = "versions" + val updateMode = "updateMode" + val defaultVersion = "defaultVersion" + } val singleVersion: String? = project.providers.gradleProperty(propertyNames.version).orNull val multipleVersions: List? = @@ -151,10 +152,10 @@ tasks.register("updateJson") { if (versions.get().isEmpty()) { logger.warn( "WARNING: no '${propertyNames.version}' or '${propertyNames.versions}' specified " + - "for task '$name'; no versions will be added to ${jsonFile.get()}. " + - "Try specifying something like '-P${propertyNames.version}=1.2.3' or " + - "'-P${propertyNames.versions}=1.2.3,4.5.6' on the gradle command line " + - "if you want to add versions (warning code bm6d5ezxzd)" + "for task '$name'; no versions will be added to ${jsonFile.get()}. " + + "Try specifying something like '-P${propertyNames.version}=1.2.3' or " + + "'-P${propertyNames.versions}=1.2.3,4.5.6' on the gradle command line " + + "if you want to add versions (warning code bm6d5ezxzd)" ) } } @@ -167,10 +168,10 @@ tasks.register("updateJson") { else -> throw Exception( "Invalid '${propertyNames.updateMode}' specified for task '$name': $it. " + - "Valid values are 'update' and 'overwrite'. " + - "Try specifying '-P${propertyNames.updateMode}=update' or " + - "'-P${propertyNames.updateMode}=overwrite' on the gradle command line. " + - "(error code v2e3cfqbnf)" + "Valid values are 'update' and 'overwrite'. " + + "Try specifying '-P${propertyNames.updateMode}=update' or " + + "'-P${propertyNames.updateMode}=overwrite' on the gradle command line. " + + "(error code v2e3cfqbnf)" ) } } @@ -180,11 +181,11 @@ tasks.register("updateJson") { if (!updateMode.isPresent) { logger.warn( "WARNING: no '${propertyNames.updateMode}' specified for task '$name'; " + - "the default update mode of 'update' will be used when updating ${jsonFile.get()}. " + - "Try specifying '-P${propertyNames.updateMode}=update' or " + - "'-P${propertyNames.updateMode}=overwrite' on the gradle command line " + - "if you want a different update mode, or just want to be explicit about " + - "which update mode is in effect (warning code tjyscqmdne)" + "the default update mode of 'update' will be used when updating ${jsonFile.get()}. " + + "Try specifying '-P${propertyNames.updateMode}=update' or " + + "'-P${propertyNames.updateMode}=overwrite' on the gradle command line " + + "if you want a different update mode, or just want to be explicit about " + + "which update mode is in effect (warning code tjyscqmdne)" ) } } @@ -195,10 +196,10 @@ tasks.register("updateJson") { if (!defaultVersion.isPresent) { logger.warn( "WARNING: no '${propertyNames.defaultVersion}' specified for task '$name'; " + - "the default version will not be updated in ${jsonFile.get()}. " + - "Try specifying something like '-P${propertyNames.defaultVersion}=1.2.3' " + - "on the gradle command line if you want to update the default version " + - "(warning code vqrbrktx9f)" + "the default version will not be updated in ${jsonFile.get()}. " + + "Try specifying something like '-P${propertyNames.defaultVersion}=1.2.3' " + + "on the gradle command line if you want to update the default version " + + "(warning code vqrbrktx9f)" ) } }