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

name.remal.gradle_plugins.dsl.utils.getGradleGroovyVersion.kt Maven / Gradle / Ivy

There is a newer version: 1.9.2
Show newest version
package name.remal.gradle_plugins.dsl.utils

import groovy.lang.GroovySystem
import name.remal.version.Version
import org.gradle.api.GradleException

fun getGradleGroovyVersion(): Version {
    val version: String
    version = try {
        GroovySystem.getVersion()
    } catch (e: NoSuchMethodError) {
        // for Groovy <1.6, we need to call org.codehaus.groovy.runtime.InvokerHelper#getVersion
        try {
            val ih = Class.forName("org.codehaus.groovy.runtime.InvokerHelper")
            val getVersion = ih.getDeclaredMethod("getVersion")
            getVersion.invoke(ih) as String
        } catch (e: Exception) {
            throw GradleException("Unable to determine Groovy version", e)
        }
    }
    return Version.parse(version)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy