name.remal.gradle_plugins.dsl.extensions.kotlin.reflect.KClass-PluginId.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugins-kotlin-dsl Show documentation
Show all versions of gradle-plugins-kotlin-dsl Show documentation
Remal Gradle plugins: gradle-plugins-kotlin-dsl
package name.remal.gradle_plugins.dsl.extensions
import name.remal.gradle_plugins.dsl.PluginId
import kotlin.reflect.KClass
fun KClass.getOrInstantiate(): T {
try {
this.objectInstance?.let { return it }
} catch (ignored: IllegalAccessException) {
// do nothing
}
return this.java.getDeclaredConstructor().apply { isAccessible = true }.newInstance()
}