summaryrefslogtreecommitdiff
path: root/buildSrc/src/main
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-04-17 22:33:00 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2021-04-18 03:01:14 +0530
commita13176a23dba82e29474cb4f7b5cbf6f49b3eb53 (patch)
tree3239024e6f4010da29f76504d7c75740c377aed8 /buildSrc/src/main
parentcada2353c184ea2918cee09ce8c69a2e4b12a2eb (diff)
build: enable explicit API automatically on all library projects
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'buildSrc/src/main')
-rw-r--r--buildSrc/src/main/java/PasswordStorePlugin.kt15
1 files changed, 15 insertions, 0 deletions
diff --git a/buildSrc/src/main/java/PasswordStorePlugin.kt b/buildSrc/src/main/java/PasswordStorePlugin.kt
index 21496f8f..f4923e04 100644
--- a/buildSrc/src/main/java/PasswordStorePlugin.kt
+++ b/buildSrc/src/main/java/PasswordStorePlugin.kt
@@ -14,10 +14,14 @@ import org.gradle.api.Project
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.compile.JavaCompile
+import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin
+import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
+import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
class PasswordStorePlugin : Plugin<Project> {
@@ -38,6 +42,7 @@ class PasswordStorePlugin : Plugin<Project> {
}
is LibraryPlugin -> {
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
+ project.configureExplicitApi()
}
is AppPlugin -> {
project.extensions.getByType<BaseAppModuleExtension>().configureAndroidApplicationOptions(project)
@@ -50,9 +55,19 @@ class PasswordStorePlugin : Plugin<Project> {
is SigningPlugin -> {
project.extensions.getByType<SigningExtension>().configureBuildSigning()
}
+ is KotlinPluginWrapper -> {
+ project.configureExplicitApi()
+ }
}
}
}
+
+ private fun Project.configureExplicitApi() {
+ configure<KotlinProjectExtension> { explicitApi() }
+ tasks.withType<KotlinCompile> {
+ kotlinOptions { freeCompilerArgs = freeCompilerArgs + listOf("-Xexplicit-api=strict") }
+ }
+ }
}
private val Project.isRoot