Skip to content

Commit 90885cb

Browse files
committed
Prefer explicitApi() instead of hand coded version
1 parent 09bd5e4 commit 90885cb

File tree

5 files changed

+8
-56
lines changed

5 files changed

+8
-56
lines changed

firebase-ai/firebase-ai.gradle.kts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
@file:Suppress("UnstableApiUsage")
1818

1919
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
20-
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
2120

2221
plugins {
2322
id("firebase-library")
@@ -73,18 +72,9 @@ android {
7372
}
7473
}
7574

76-
kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_1_8 } }
77-
78-
// Enable Kotlin "Explicit API Mode". This causes the Kotlin compiler to fail if any
79-
// classes, methods, or properties have implicit `public` visibility. This check helps
80-
// avoid accidentally leaking elements into the public API, requiring that any public
81-
// element be explicitly declared as `public`.
82-
// https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md
83-
// https://chao2zhang.medium.com/explicit-api-mode-for-kotlin-on-android-b8264fdd76d1
84-
tasks.withType<KotlinJvmCompile>().configureEach {
85-
if (!name.contains("test", ignoreCase = true)) {
86-
compilerOptions.freeCompilerArgs.add("-Xexplicit-api=strict")
87-
}
75+
kotlin {
76+
compilerOptions { jvmTarget = JvmTarget.JVM_1_8 }
77+
explicitApi()
8878
}
8979

9080
dependencies {

firebase-dataconnect/connectors/connectors.gradle.kts

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

17-
import org.gradle.kotlin.dsl.withType
1817
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
19-
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
2018

2119
plugins {
2220
id("com.android.library")
@@ -70,6 +68,7 @@ kotlin {
7068
jvmTarget = JvmTarget.JVM_1_8
7169
optIn.add("kotlin.RequiresOptIn")
7270
}
71+
explicitApi()
7372
}
7473

7574
dependencies {
@@ -100,15 +99,3 @@ dependencies {
10099
androidTestImplementation(libs.truth.liteproto.extension)
101100
androidTestImplementation(libs.turbine)
102101
}
103-
104-
// Enable Kotlin "Explicit API Mode". This causes the Kotlin compiler to fail if any
105-
// classes, methods, or properties have implicit `public` visibility. This check helps
106-
// avoid accidentally leaking elements into the public API, requiring that any public
107-
// element be explicitly declared as `public`.
108-
// https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md
109-
// https://chao2zhang.medium.com/explicit-api-mode-for-kotlin-on-android-b8264fdd76d1
110-
tasks.withType<KotlinJvmCompile>().configureEach {
111-
if (!name.contains("test", ignoreCase = true)) {
112-
compilerOptions.freeCompilerArgs.add("-Xexplicit-api=strict")
113-
}
114-
}

firebase-dataconnect/firebase-dataconnect.gradle.kts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
import com.google.firebase.dataconnect.gradle.plugin.DataConnectExecutableVersionsRegistry
1818
import com.google.firebase.dataconnect.gradle.plugin.UpdateDataConnectExecutableVersionsTask
19-
import org.gradle.kotlin.dsl.withType
2019
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
21-
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
2220

2321
plugins {
2422
id("firebase-library")
@@ -81,6 +79,7 @@ kotlin {
8179
jvmTarget = JvmTarget.JVM_1_8
8280
optIn.add("kotlin.RequiresOptIn")
8381
}
82+
explicitApi()
8483
}
8584

8685
protobuf {
@@ -155,18 +154,6 @@ dependencies {
155154
androidTestImplementation(libs.turbine)
156155
}
157156

158-
// Enable Kotlin "Explicit API Mode". This causes the Kotlin compiler to fail if any
159-
// classes, methods, or properties have implicit `public` visibility. This check helps
160-
// avoid accidentally leaking elements into the public API, requiring that any public
161-
// element be explicitly declared as `public`.
162-
// https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md
163-
// https://chao2zhang.medium.com/explicit-api-mode-for-kotlin-on-android-b8264fdd76d1
164-
tasks.withType<KotlinJvmCompile>().configureEach {
165-
if (!name.contains("test", ignoreCase = true)) {
166-
compilerOptions.freeCompilerArgs.add("-Xexplicit-api=strict")
167-
}
168-
}
169-
170157
// Registers a Gradle task that updates the JSON file that stores the list of Data Connect
171158
// executable versions. The task gets the list of all versions from the Internet and then
172159
// updates the JSON file with their sizes and hashes.

firebase-functions/firebase-functions.gradle.kts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
16-
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
1716

1817
plugins {
1918
id("firebase-library")
@@ -57,19 +56,8 @@ android {
5756
lint { targetSdk = targetSdkVersion }
5857
}
5958

60-
kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_1_8 } }
59+
kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_1_8 } explicitApi()}
6160

62-
// Enable Kotlin "Explicit API Mode". This causes the Kotlin compiler to fail if any
63-
// classes, methods, or properties have implicit `public` visibility. This check helps
64-
// avoid accidentally leaking elements into the public API, requiring that any public
65-
// element be explicitly declared as `public`.
66-
// https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md
67-
// https://chao2zhang.medium.com/explicit-api-mode-for-kotlin-on-android-b8264fdd76d1
68-
tasks.withType<KotlinJvmCompile>().configureEach {
69-
if (!name.contains("test", ignoreCase = true)) {
70-
compilerOptions.freeCompilerArgs.add("-Xexplicit-api=strict")
71-
}
72-
}
7361

7462
dependencies {
7563
javadocClasspath("org.codehaus.mojo:animal-sniffer-annotations:1.21")

firebase-sessions/firebase-sessions.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ android {
6161
}
6262
}
6363

64-
kotlin {
64+
kotlin {
6565
explicitApi()
66-
compilerOptions { jvmTarget = JvmTarget.JVM_1_8 }
66+
compilerOptions { jvmTarget = JvmTarget.JVM_1_8 }
6767
}
6868

6969
dependencies {

0 commit comments

Comments
 (0)