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

netflix.nebula.NebulaKotlinPlugin.groovy Maven / Gradle / Ivy

Go to download

Provides the Kotlin plugin via the Gradle plugin portal and allows Kotlin library versions to be omitted

There is a newer version: 2.0.2
Show newest version
package netflix.nebula

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.plugin.KotlinPlugin

class NebulaKotlinPlugin implements Plugin {
    @Override
    void apply(Project project) {
        project.with {
            plugins.apply('kotlin')

            def kotlinVersion = loadKotlinVersion()

            dependencies {
                compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
            }

            configurations.all({ configuration ->
                configuration.resolutionStrategy.eachDependency { details ->
                    def requested = details.requested
                    if (requested.group.equals("org.jetbrains.kotlin") && requested.version.isEmpty()) {
                        details.useTarget("${requested.group}:${requested.name}:$kotlinVersion")
                    }
                }
            })
        }
    }

    static def loadKotlinVersion() {
        def props = new Properties()
        def propFileName = "project.properties"
        def inputStream = KotlinPlugin.getClassLoader().getResourceAsStream(propFileName)

        if (inputStream == null) {
            throw new FileNotFoundException("property file '$propFileName' not found in the classpath")
        }

        props.load(inputStream)

        def projectVersion = props["project.version"] as String
        return projectVersion
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy