@@ -34,7 +34,7 @@ open class AtomicFUGradlePlugin : Plugin<Project> {
34
34
val pluginVersion = rootProject.buildscript.configurations.findByName(" classpath" )
35
35
?.allDependencies?.find { it.name == " atomicfu-gradle-plugin" }?.version
36
36
extensions.add(EXTENSION_NAME , AtomicFUPluginExtension (pluginVersion))
37
- if (rootProject.findProperty (ENABLE_IR_TRANSFORMATION ).toString().toBoolean( )) {
37
+ if (rootProject.getBooleanProperty (ENABLE_IR_TRANSFORMATION )) {
38
38
plugins.apply (AtomicfuKotlinGradleSubplugin ::class .java)
39
39
}
40
40
configureDependencies()
@@ -86,6 +86,15 @@ private fun Project.configureTasks() {
86
86
}
87
87
}
88
88
89
+ private fun Project.getBooleanProperty (name : String ) =
90
+ rootProject.findProperty(name)?.toString()?.toBooleanStrict() ? : false
91
+
92
+ private fun String.toBooleanStrict (): Boolean = when (this ) {
93
+ " true" -> true
94
+ " false" -> false
95
+ else -> throw IllegalArgumentException (" The string doesn't represent a boolean value: $this " )
96
+ }
97
+
89
98
private fun Project.needsJsIrTransformation (target : KotlinTarget ): Boolean =
90
99
config.transformJs && target.isJsIrTarget()
91
100
@@ -264,7 +273,7 @@ fun Project.sourceSetsByCompilation(): Map<KotlinSourceSet, List<KotlinCompilati
264
273
}
265
274
266
275
fun Project.configureMultiplatformPluginDependencies (version : String ) {
267
- if (rootProject.findProperty (" kotlin.mpp.enableGranularSourceSetsMetadata" ).toString().toBoolean( )) {
276
+ if (rootProject.getBooleanProperty (" kotlin.mpp.enableGranularSourceSetsMetadata" )) {
268
277
addCompilerPluginDependency()
269
278
val mainConfigurationName = project.extensions.getByType(KotlinMultiplatformExtension ::class .java).sourceSets
270
279
.getByName(KotlinSourceSet .COMMON_MAIN_SOURCE_SET_NAME )
0 commit comments