Skip to content

Commit f373e41

Browse files
committed
Merge remote-tracking branch 'origin/main' into UserDefinedEnumsInternal
2 parents de49230 + db3bd7a commit f373e41

18 files changed

+135
-63
lines changed

.github/workflows/dataconnect.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ jobs:
134134
135135
./gradlew \
136136
--profile \
137+
--warning-mode all \
137138
${{ (inputs.gradleInfoLog && '--info') || '' }} \
138139
:firebase-dataconnect:assembleDebugAndroidTest
139140
@@ -222,7 +223,7 @@ jobs:
222223
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
223224
disable-animations: true
224225
script: |
225-
set -eux && ./gradlew ${{ (inputs.gradleInfoLog && '--info') || '' }} :firebase-dataconnect:connectedCheck :firebase-dataconnect:connectors:connectedCheck
226+
set -eux && ./gradlew --warning-mode all ${{ (inputs.gradleInfoLog && '--info') || '' }} :firebase-dataconnect:connectedCheck :firebase-dataconnect:connectors:connectedCheck
226227
227228
- name: Upload Log Files
228229
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1

.github/workflows/dataconnect_demo_app.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,15 @@ jobs:
108108
--project-dir firebase-dataconnect/demo \
109109
${{ (inputs.gradleInfoLog && '--info') || '' }} \
110110
--profile \
111+
--warning-mode all \
111112
-PdataConnect.demo.firebaseCommand=${{ env.FDC_FIREBASE_COMMAND }} \
112113
assemble test
113114
114115
- name: gradle dokkaGeneratePublicationHtml
115116
run: |
116117
set -x
117118
firebase-dataconnect/demo/gradlew \
119+
--warning-mode all \
118120
--project-dir firebase-dataconnect/demo \
119121
${{ (inputs.gradleInfoLog && '--info') || '' }} \
120122
dokkaGeneratePublicationHtml
@@ -176,6 +178,7 @@ jobs:
176178
run: |
177179
set -x
178180
firebase-dataconnect/demo/gradlew \
181+
--warning-mode all \
179182
--project-dir firebase-dataconnect/demo \
180183
--no-daemon \
181184
${{ (inputs.gradleInfoLog && '--info') || '' }} \

firebase-dataconnect/CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
- [changed] Ignore unknown fields in response data instead of throwing a
44
`DataConnectOperationException` with message "decoding data from the server's response failed: An
5-
unknown field for index -3"
6-
([#7314](https://github.com/firebase/firebase-android-sdk/pull/7314))
5+
unknown field for index -3" ([#7314](https://github.com/firebase/firebase-android-sdk/pull/7314))
76
- [changed] Added classes `EnumValue` and `EnumValueSerializer`. These classes are identical to
87
those produced by the Data Connect code generator; however, a future version of the code generator
98
will start using these classes from the SDK rather than generating them.

firebase-dataconnect/androidTestutil/androidTestutil.gradle.kts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
17+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1818

1919
plugins {
2020
id("com.android.library")
@@ -31,14 +31,16 @@ android {
3131
compileSdk = compileSdkVersion
3232
defaultConfig {
3333
minSdk = minSdkVersion
34-
targetSdk = targetSdkVersion
3534
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3635
}
3736
compileOptions {
3837
sourceCompatibility = JavaVersion.VERSION_1_8
3938
targetCompatibility = JavaVersion.VERSION_1_8
4039
}
41-
kotlinOptions { jvmTarget = "1.8" }
40+
41+
@Suppress("UnstableApiUsage") testOptions { targetSdk = targetSdkVersion }
42+
43+
lint { targetSdk = targetSdkVersion }
4244

4345
packaging {
4446
resources {
@@ -48,6 +50,13 @@ android {
4850
}
4951
}
5052

53+
kotlin {
54+
compilerOptions {
55+
jvmTarget = JvmTarget.JVM_1_8
56+
optIn.add("kotlin.RequiresOptIn")
57+
}
58+
}
59+
5160
dependencies {
5261
implementation(project(":firebase-dataconnect"))
5362
implementation(project(":firebase-dataconnect:testutil"))
@@ -66,7 +75,3 @@ dependencies {
6675
implementation(libs.truth)
6776
implementation(libs.turbine)
6877
}
69-
70-
tasks.withType<KotlinCompile>().all {
71-
kotlinOptions { freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn") }
72-
}

firebase-dataconnect/connectors/connectors.gradle.kts

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

1717
import com.google.firebase.dataconnect.gradle.plugin.UpdateDataConnectExecutableVersionsTask
18-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
18+
import org.gradle.kotlin.dsl.withType
19+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
20+
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
1921

2022
plugins {
2123
id("com.android.library")
@@ -33,23 +35,24 @@ android {
3335
compileSdk = compileSdkVersion
3436
defaultConfig {
3537
minSdk = minSdkVersion
36-
targetSdk = targetSdkVersion
3738
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3839
}
3940
compileOptions {
4041
sourceCompatibility = JavaVersion.VERSION_1_8
4142
targetCompatibility = JavaVersion.VERSION_1_8
4243
}
43-
kotlinOptions { jvmTarget = "1.8" }
4444

4545
@Suppress("UnstableApiUsage")
4646
testOptions {
47+
targetSdk = targetSdkVersion
4748
unitTests {
4849
isIncludeAndroidResources = true
4950
isReturnDefaultValues = true
5051
}
5152
}
5253

54+
lint { targetSdk = targetSdkVersion }
55+
5356
packaging {
5457
resources {
5558
excludes.add("META-INF/LICENSE.md")
@@ -63,6 +66,13 @@ android {
6366
}
6467
}
6568

69+
kotlin {
70+
compilerOptions {
71+
jvmTarget = JvmTarget.JVM_1_8
72+
optIn.add("kotlin.RequiresOptIn")
73+
}
74+
}
75+
6676
dependencies {
6777
implementation(project(":firebase-dataconnect"))
6878
implementation(libs.kotlinx.coroutines.core)
@@ -92,21 +102,15 @@ dependencies {
92102
androidTestImplementation(libs.turbine)
93103
}
94104

95-
tasks.withType<KotlinCompile>().all {
96-
kotlinOptions { freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn") }
97-
}
98-
99105
// Enable Kotlin "Explicit API Mode". This causes the Kotlin compiler to fail if any
100106
// classes, methods, or properties have implicit `public` visibility. This check helps
101107
// avoid accidentally leaking elements into the public API, requiring that any public
102108
// element be explicitly declared as `public`.
103109
// https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md
104110
// https://chao2zhang.medium.com/explicit-api-mode-for-kotlin-on-android-b8264fdd76d1
105-
tasks.withType<KotlinCompile>().all {
111+
tasks.withType<KotlinJvmCompile>().configureEach {
106112
if (!name.contains("test", ignoreCase = true)) {
107-
if (!kotlinOptions.freeCompilerArgs.contains("-Xexplicit-api=strict")) {
108-
kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict"
109-
}
113+
compilerOptions.freeCompilerArgs.add("-Xexplicit-api=strict")
110114
}
111115
}
112116

firebase-dataconnect/demo/build.gradle.kts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
1818
import java.nio.charset.StandardCharsets
19+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1920

2021
plugins {
2122
// Use whichever versions of these dependencies suit your application.
@@ -83,7 +84,13 @@ android {
8384
isCoreLibraryDesugaringEnabled = true
8485
}
8586
buildFeatures.viewBinding = true
86-
kotlinOptions.jvmTarget = "1.8"
87+
}
88+
89+
kotlin {
90+
compilerOptions {
91+
jvmTarget = JvmTarget.JVM_1_8
92+
optIn.add("kotlin.RequiresOptIn")
93+
}
8794
}
8895

8996
spotless {
@@ -115,7 +122,7 @@ spotless {
115122
target("**/*.xml")
116123
targetExclude("build/")
117124
trimTrailingWhitespace()
118-
indentWithSpaces(2)
125+
leadingTabsToSpaces(2)
119126
endWithNewline()
120127
}
121128
}

firebase-dataconnect/firebase-dataconnect.gradle.kts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
17+
import org.gradle.kotlin.dsl.withType
18+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
19+
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
1820

1921
plugins {
2022
id("firebase-library")
@@ -28,6 +30,7 @@ firebaseLibrary {
2830
libraryGroup = "dataconnect"
2931
testLab.enabled = false
3032
publishJavadoc = true
33+
onlyPublishKotlindoc = true
3134
releaseNotes {
3235
name.set("{{data_connect_short}}")
3336
versionName.set("data-connect")
@@ -43,15 +46,13 @@ android {
4346
compileSdk = compileSdkVersion
4447
defaultConfig {
4548
minSdk = minSdkVersion
46-
targetSdk = targetSdkVersion
4749
multiDexEnabled = true
4850
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
4951
}
5052
compileOptions {
5153
sourceCompatibility = JavaVersion.VERSION_1_8
5254
targetCompatibility = JavaVersion.VERSION_1_8
5355
}
54-
kotlinOptions { jvmTarget = "1.8" }
5556

5657
@Suppress("UnstableApiUsage")
5758
testOptions {
@@ -72,6 +73,13 @@ android {
7273
}
7374
}
7475

76+
kotlin {
77+
compilerOptions {
78+
jvmTarget = JvmTarget.JVM_1_8
79+
optIn.add("kotlin.RequiresOptIn")
80+
}
81+
}
82+
7583
protobuf {
7684
protoc { artifact = "${libs.protoc.get()}" }
7785
plugins {
@@ -144,20 +152,14 @@ dependencies {
144152
androidTestImplementation(libs.turbine)
145153
}
146154

147-
tasks.withType<KotlinCompile>().all {
148-
kotlinOptions { freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn") }
149-
}
150-
151155
// Enable Kotlin "Explicit API Mode". This causes the Kotlin compiler to fail if any
152156
// classes, methods, or properties have implicit `public` visibility. This check helps
153157
// avoid accidentally leaking elements into the public API, requiring that any public
154158
// element be explicitly declared as `public`.
155159
// https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md
156160
// https://chao2zhang.medium.com/explicit-api-mode-for-kotlin-on-android-b8264fdd76d1
157-
tasks.withType<KotlinCompile>().all {
161+
tasks.withType<KotlinJvmCompile>().configureEach {
158162
if (!name.contains("test", ignoreCase = true)) {
159-
if (!kotlinOptions.freeCompilerArgs.contains("-Xexplicit-api=strict")) {
160-
kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict"
161-
}
163+
compilerOptions.freeCompilerArgs.add("-Xexplicit-api=strict")
162164
}
163165
}

firebase-dataconnect/gradleplugin/plugin/src/main/kotlin/com/google/firebase/dataconnect/gradle/plugin/DataConnectExecutableDownloadTask.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ import java.net.HttpURLConnection
2020
import java.net.URL
2121
import java.security.MessageDigest
2222
import java.util.regex.Pattern
23+
import javax.inject.Inject
2324
import kotlin.time.Duration.Companion.seconds
2425
import kotlin.time.DurationUnit
2526
import kotlin.time.toDuration
2627
import org.gradle.api.DefaultTask
2728
import org.gradle.api.Task
2829
import org.gradle.api.file.DirectoryProperty
30+
import org.gradle.api.file.FileSystemOperations
2931
import org.gradle.api.file.RegularFileProperty
3032
import org.gradle.api.provider.Property
3133
import org.gradle.api.tasks.Input
@@ -34,6 +36,7 @@ import org.gradle.api.tasks.Internal
3436
import org.gradle.api.tasks.Optional
3537
import org.gradle.api.tasks.OutputFile
3638
import org.gradle.api.tasks.TaskAction
39+
import org.gradle.process.ExecOperations
3740

3841
abstract class DataConnectExecutableDownloadTask : DefaultTask() {
3942

@@ -47,6 +50,10 @@ abstract class DataConnectExecutableDownloadTask : DefaultTask() {
4750

4851
@get:OutputFile abstract val outputFile: RegularFileProperty
4952

53+
@get:Inject abstract val fileSystemOperations: FileSystemOperations
54+
55+
@get:Inject abstract val execOperations: ExecOperations
56+
5057
@TaskAction
5158
fun run() {
5259
val inputFile: File? = inputFile.orNull?.asFile
@@ -62,7 +69,7 @@ abstract class DataConnectExecutableDownloadTask : DefaultTask() {
6269
logger.info("outputFile: {}", outputFile)
6370

6471
logger.info("Deleting build directory: {}", buildDirectory)
65-
project.delete(buildDirectory)
72+
fileSystemOperations.delete { it.delete(buildDirectory) }
6673

6774
if (inputFile !== null && version !== null) {
6875
throw DataConnectGradleException(
@@ -74,7 +81,7 @@ abstract class DataConnectExecutableDownloadTask : DefaultTask() {
7481
} else if (inputFile !== null) {
7582
runWithFile(inputFile = inputFile, outputFile = outputFile)
7683
} else if (version !== null) {
77-
downloadDataConnectExecutable(version, operatingSystem, outputFile)
84+
downloadDataConnectExecutable(version, operatingSystem, outputFile, execOperations)
7885
verifyOutputFile(outputFile, operatingSystem, version)
7986
} else {
8087
throw DataConnectGradleException(
@@ -184,7 +191,7 @@ abstract class DataConnectExecutableDownloadTask : DefaultTask() {
184191
}
185192

186193
logger.info("Copying {} to {}", inputFile, outputFile)
187-
project.copy {
194+
fileSystemOperations.copy {
188195
it.from(inputFile)
189196
it.into(outputFile.parentFile)
190197
it.rename(Pattern.quote(inputFile.name), Pattern.quote(outputFile.name))
@@ -195,7 +202,8 @@ abstract class DataConnectExecutableDownloadTask : DefaultTask() {
195202
fun Task.downloadDataConnectExecutable(
196203
version: String,
197204
operatingSystem: OperatingSystem,
198-
outputFile: File
205+
outputFile: File,
206+
execOperations: ExecOperations
199207
) {
200208
val osName =
201209
when (operatingSystem) {
@@ -208,7 +216,7 @@ abstract class DataConnectExecutableDownloadTask : DefaultTask() {
208216
URL("https://storage.googleapis.com/firemat-preview-drop/emulator/$downloadFileName")
209217

210218
logger.info("Downloading {} to {}", url, outputFile)
211-
project.mkdir(outputFile.parentFile)
219+
outputFile.parentFile.mkdirs()
212220

213221
val connection = url.openConnection() as HttpURLConnection
214222
connection.requestMethod = "GET"
@@ -251,7 +259,7 @@ abstract class DataConnectExecutableDownloadTask : DefaultTask() {
251259
}
252260

253261
if (operatingSystem != OperatingSystem.Windows) {
254-
project.exec { execSpec ->
262+
execOperations.exec { execSpec ->
255263
execSpec.run {
256264
executable = "chmod"
257265
args = listOf("a+x", outputFile.absolutePath)

firebase-dataconnect/gradleplugin/plugin/src/main/kotlin/com/google/firebase/dataconnect/gradle/plugin/DataConnectExecutableLauncher.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package com.google.firebase.dataconnect.gradle.plugin
1717

1818
import java.io.File
1919
import org.gradle.api.Task
20+
import org.gradle.process.ExecOperations
2021

2122
interface DataConnectExecutableConfig {
2223
var outputDirectory: File?
@@ -33,6 +34,7 @@ fun Task.runDataConnectExecutable(
3334
dataConnectExecutable: File,
3435
subCommand: List<String>,
3536
configDirectory: File,
37+
execOperations: ExecOperations,
3638
configure: DataConnectExecutableConfig.() -> Unit,
3739
) {
3840
val config =
@@ -48,11 +50,11 @@ fun Task.runDataConnectExecutable(
4850
}
4951
.apply(configure)
5052

51-
val logFile = config.logFile?.also { project.mkdir(it.parentFile) }
53+
val logFile = config.logFile?.also { it.parentFile.mkdirs() }
5254
val logFileStream = logFile?.outputStream()
5355

5456
try {
55-
project.exec { execSpec ->
57+
execOperations.exec { execSpec ->
5658
execSpec.run {
5759
executable(dataConnectExecutable)
5860
isIgnoreExitValue = false

0 commit comments

Comments
 (0)