All Downloads are FREE. Search and download functionalities are using the official Maven repository.

name.remal.gradle_plugins.dsl.extensions.kotlin.reflect.KClass-PluginId.kt Maven / Gradle / Ivy

There is a newer version: 1.9.2
Show newest version
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()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy