Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions tapmoc-gradle-plugin/src/kgp/kotlin/tapmoc/internal/KgpImpl.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tapmoc.internal

import java.lang.reflect.Method
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.provider.ProviderFactory
Expand All @@ -19,22 +18,12 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetsContainer
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion

private var method: Method? = null
private var firstTime = true

@Synchronized
private fun compilerOptionsMethod(): Method? {
if (firstTime) {
firstTime = false

method = try {
KotlinMultiplatformExtension::class.java.getMethod("getCompilerOptions")
} catch (_: NoSuchMethodException) {
null
}
private val compilerOptionsMethod by lazy {
try {
KotlinMultiplatformExtension::class.java.getMethod("getCompilerOptions")
} catch (_: NoSuchMethodException) {
null
}

return method
}

private class KgpImpl(private val dependencyHandler: DependencyHandler, extension: Any, private val providers: ProviderFactory, private val kgpVersion: String) : Kgp {
Expand Down Expand Up @@ -79,7 +68,7 @@ private class KgpImpl(private val dependencyHandler: DependencyHandler, extensio
}
}
is KotlinMultiplatformExtension -> {
val compilerOptions = compilerOptionsMethod()
val compilerOptions = compilerOptionsMethod
if (compilerOptions != null) {
(compilerOptions.invoke(kotlinProjectExtension) as KotlinCommonCompilerOptions).apply {
/**
Expand Down
Loading