Skip to content

Commit 72ae373

Browse files
committed
Downgrade kotlin version in firebase-dataconnect/gradleplugin from 1.9.25 to 1.8.22 to match the version used in ../../buildSrc
1 parent e414d9f commit 72ae373

File tree

3 files changed

+61
-20
lines changed

3 files changed

+61
-20
lines changed

firebase-dataconnect/gradleplugin/gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
androidGradlePlugin = "8.2.1"
3-
kotlin = "1.9.25"
3+
kotlin = "1.8.22"
44

55
[libraries]
66
android-gradlePlugin-api = { group = "com.android.tools.build", name = "gradle-api", version.ref = "androidGradlePlugin" }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.firebase.dataconnect.gradle.plugin;
17+
18+
import org.gradle.api.Transformer;
19+
import org.jetbrains.annotations.NotNull;
20+
import org.jetbrains.annotations.Nullable;
21+
22+
// TODO: Remove this interface and use Transformer directly once the Kotlin version is upgraded to
23+
// a later version that doesn't require it, such as 1.9.25. Using this interface works around the
24+
// following Kotlin compiler error:
25+
//
26+
// > Task :plugin:compileKotlin FAILED
27+
// e: DataConnectGradlePlugin.kt:93:15 Type mismatch: inferred type is RegularFile? but TypeVariable(S) was expected
28+
// e: DataConnectGradlePlugin.kt:102:15 Type mismatch: inferred type is String? but TypeVariable(S) was expected
29+
// e: DataConnectGradlePlugin.kt:111:15 Type mismatch: inferred type is DataConnectExecutable.VerificationInfo? but TypeVariable(S) was expected
30+
public interface TransformerInterop<OUT, IN> extends Transformer<OUT, IN> {
31+
32+
@Override
33+
@Nullable OUT transform(@NotNull IN in);
34+
35+
}

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

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import java.util.Locale
2626
import org.gradle.api.Plugin
2727
import org.gradle.api.Project
2828
import org.gradle.api.file.Directory
29-
import org.gradle.api.file.RegularFile
3029
import org.gradle.api.logging.Logging
3130
import org.gradle.api.plugins.ExtensionAware
3231
import org.gradle.api.provider.Provider
@@ -89,31 +88,38 @@ abstract class DataConnectGradlePlugin : Plugin<Project> {
8988
val dataConnectExecutable = dataConnectProviders.dataConnectExecutable
9089
buildDirectory.set(baseBuildDirectory.map { it.dir("executable") })
9190
inputFile.set(
92-
dataConnectExecutable.map {
93-
when (it) {
94-
is DataConnectExecutable.File -> project.layout.projectDirectory.file(it.file.path)
95-
is DataConnectExecutable.RegularFile -> it.file
96-
is DataConnectExecutable.Version -> null
91+
dataConnectExecutable.map(
92+
TransformerInterop {
93+
when (it) {
94+
is DataConnectExecutable.File ->
95+
project.layout.projectDirectory.file(it.file.path)
96+
is DataConnectExecutable.RegularFile -> it.file
97+
is DataConnectExecutable.Version -> null
98+
}
9799
}
98-
}
100+
)
99101
)
100102
version.set(
101-
dataConnectExecutable.map {
102-
when (it) {
103-
is DataConnectExecutable.File -> null
104-
is DataConnectExecutable.RegularFile -> null
105-
is DataConnectExecutable.Version -> it.version
103+
dataConnectExecutable.map(
104+
TransformerInterop {
105+
when (it) {
106+
is DataConnectExecutable.File -> null
107+
is DataConnectExecutable.RegularFile -> null
108+
is DataConnectExecutable.Version -> it.version
109+
}
106110
}
107-
}
111+
)
108112
)
109113
verificationInfo.set(
110-
dataConnectExecutable.map {
111-
when (it) {
112-
is DataConnectExecutable.File -> it.verificationInfo
113-
is DataConnectExecutable.RegularFile -> it.verificationInfo
114-
is DataConnectExecutable.Version -> it.verificationInfo
114+
dataConnectExecutable.map(
115+
TransformerInterop {
116+
when (it) {
117+
is DataConnectExecutable.File -> it.verificationInfo
118+
is DataConnectExecutable.RegularFile -> it.verificationInfo
119+
is DataConnectExecutable.Version -> it.verificationInfo
120+
}
115121
}
116-
}
122+
)
117123
)
118124
outputFile.set(
119125
dataConnectExecutable.map {

0 commit comments

Comments
 (0)