Provides the Kotlin plugin via the Gradle plugin portal, and adds ergonomic improvements over the default plugin:
- Automatically depends on the standard library
- Allows Kotlin library versions to be omitted, inferring them automatically from the plugin version
- For Kotlin 1.1 and later, sets the
-jvm-target
and uses the jre standard library based on thesourceCompatibility
- Use the https://github.com/nebula-plugins/gradle-java-cross-compile-plugin to set the
targetJdk
if desired
- Use the https://github.com/nebula-plugins/gradle-java-cross-compile-plugin to set the
- Bundles the
kotlin-allopen
andkotlin-noarg
plugins to allow them to be applied without adding them manually to the classpath
Refer to the Gradle Plugin Portal for instructions on how to apply the main plugin.
The plugin simplifies a basic Kotlin build script to:
plugins {
id 'nebula.kotlin' version '1.3.60'
}
repositories {
mavenCentral() // or jcenter()
}
plugins {
id 'nebula.kotlin' version '1.3.60'
}
repositories {
mavenCentral() // or jcenter()
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-reflect'
}
There are cases were we only want to use kotlin for specific configurations and applying the plugin added stdlib
to implementation
by default.
Starting on 1.3.60
, it is possible to set the default configuration for stdlib
via stdlibConfiguration
. For example:
plugins {
id 'nebula.kotlin' version '1.3.60'
}
repositories {
mavenCentral() // or jcenter()
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-reflect'
}
configurations {
myConfig
}
nebulaKotlin {
stdlibConfiguration = "myConfig"
}
This plugin will apply our opinions for default version of additional dependencies but won't add stdlib
by default
plugins {
id 'nebula.kotlin-nodep' version '1.3.60'
}
The version for kotlin-reflect
will be automatically set to match the Kotlin version (1.3.60
).
- IntelliJ doesn't set the
-jvm-target
compiler option based on the Java SDK setting for the project, and can cause the compiler inlining failure if it tries to inline classes compiled with Gradle. Configure the JVM target in IntelliJ preferences to avoid this