Skip to content

Commit 1dc7c4d

Browse files
authored
Merge branch 'main' into daymon-bump-protobuf
2 parents cd95049 + b49d448 commit 1dc7c4d

File tree

10 files changed

+495
-241
lines changed

10 files changed

+495
-241
lines changed

firebase-dataconnect/androidTestutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/DataConnectIntegrationTestBase.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ package com.google.firebase.dataconnect.testutil
1919
import androidx.test.ext.junit.runners.AndroidJUnit4
2020
import com.google.firebase.dataconnect.ConnectorConfig
2121
import com.google.firebase.util.nextAlphanumericString
22+
import io.kotest.property.Arb
2223
import io.kotest.property.RandomSource
24+
import io.kotest.property.arbitrary.Codepoint
25+
import io.kotest.property.arbitrary.alphanumeric
26+
import io.kotest.property.arbitrary.arbitrary
27+
import io.kotest.property.arbitrary.string
2328
import kotlin.random.Random
2429
import org.junit.Rule
2530
import org.junit.rules.TestName
@@ -40,6 +45,31 @@ abstract class DataConnectIntegrationTestBase {
4045

4146
val rs: RandomSource by randomSeedTestRule.rs
4247

48+
/**
49+
* Generates and returns a string containing random alphanumeric characters, including the name of
50+
* the currently-running test as returned from [testName].
51+
*
52+
* @param string The [Arb] to use to generate the random string; if not specified, then an [Arb]
53+
* that generates strings of 20 alphanumeric characters is used.
54+
* @param prefix A prefix to include in the returned string; if null (the default) then no prefix
55+
* will be included.
56+
* @return a string containing random characters and incorporating the other information
57+
* identified above.
58+
*/
59+
fun Arb.Companion.alphanumericString(
60+
string: Arb<String> = Arb.string(20, Codepoint.alphanumeric()),
61+
prefix: String? = null,
62+
): Arb<String> = arbitrary {
63+
buildString {
64+
if (prefix != null) {
65+
append(prefix)
66+
}
67+
append(testName)
68+
append("_")
69+
append(string.bind())
70+
}
71+
}
72+
4373
companion object {
4474
val testConnectorConfig: ConnectorConfig
4575
get() =

firebase-dataconnect/connectors/connectors.gradle.kts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
18+
import com.google.firebase.dataconnect.gradle.plugin.UpdateDataConnectExecutableVersionsTask
1819

1920
plugins {
2021
id("com.android.library")
@@ -109,3 +110,41 @@ tasks.withType<KotlinCompile>().all {
109110
}
110111
}
111112
}
113+
114+
// Adds a Gradle task that updates the JSON file that stores the list of Data Connect
115+
// executable versions.
116+
//
117+
// Example 1: Add versions 1.4.3 and 1.4.4 to the JSON file, and set 1.4.4 as the default:
118+
// ../../gradlew -Pversions=1.4.3,1.4.4 -PdefaultVersion=1.4.4 updateJson --info
119+
//
120+
// Example 2: Add version 1.2.3 to the JSON file, but do not change the default version:
121+
// ../../gradlew -Pversion=1.2.3 updateJson --info
122+
//
123+
// The `--info` argument can be omitted; it merely controls the level of log output.
124+
tasks.register<UpdateDataConnectExecutableVersionsTask>("updateJson") {
125+
outputs.upToDateWhen { false }
126+
jsonFile.set(project.layout.projectDirectory.file(
127+
"../gradleplugin/plugin/src/main/resources/com/google/firebase/dataconnect/gradle/" +
128+
"plugin/DataConnectExecutableVersions.json"))
129+
workDirectory.set(project.layout.buildDirectory.dir("updateJson"))
130+
131+
val singleVersion: String? = project.providers.gradleProperty("version").orNull
132+
val multipleVersions: List<String>? = project.providers.gradleProperty("versions").orNull?.split(',')
133+
versions.set(buildList {
134+
singleVersion?.let{add(it)}
135+
multipleVersions?.let{addAll(it)}
136+
if (isEmpty()) {
137+
throw Exception("bm6d5ezxzd 'version' or 'versions' property must be specified")
138+
}
139+
})
140+
141+
updateMode.set(project.providers.gradleProperty("updateMode").map {
142+
when (it) {
143+
"overwrite" -> UpdateDataConnectExecutableVersionsTask.UpdateMode.Overwrite
144+
"update" -> UpdateDataConnectExecutableVersionsTask.UpdateMode.Update
145+
else -> throw Exception("ahe4zadcjs 'updateMode' must be 'overwrite' or 'update', but got: $it")
146+
}
147+
})
148+
149+
defaultVersion.set(project.providers.gradleProperty("defaultVersion"))
150+
}

0 commit comments

Comments
 (0)