Skip to content

Instantly share code, notes, and snippets.

@nikolaybotevb

nikolaybotevb/build.gradle

Last active Mar 17, 2020
Embed
What would you like to do?
Gradle Build with Java 9 Modules and Kotlin Support (root project)
plugins {
id 'idea'
id 'com.zyxist.chainsaw' version '0.3.1' apply false
id "org.jetbrains.kotlin.jvm" version "1.2.31" apply false
}
subprojects {
apply plugin: 'idea'
apply plugin: 'java-library'
apply plugin: 'com.zyxist.chainsaw'
}
// The idea plugin derives the JDK name as '1.9' while IDEA uses '9' as the default name for JDK 9
idea.project.jdkName = '9'
apply plugin: 'org.jetbrains.kotlin.jvm'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
}
// Enable Kotlin compilation to Java 8 class files wiht method parameter name metadata
compileKotlin.kotlinOptions.jvmTarget = '1.8'
compileKotlin.kotlinOptions.javaParameters = true
// As per https://stackoverflow.com/a/47669720
// See also https://discuss.kotlinlang.org/t/kotlin-support-for-java-9-module-system/2499/9
compileKotlin.destinationDir = compileJava.destinationDir
jar.duplicatesStrategy = "exclude"
// Allow cross-references between java and kotlin
sourceSets.main.kotlin.srcDirs += 'src/main/java'
@elect86

This comment has been minimized.

Copy link

@elect86 elect86 commented Mar 17, 2020

Hi,

is this still actual?

@nikolaybotevb

This comment has been minimized.

Copy link
Owner Author

@nikolaybotevb nikolaybotevb commented Mar 17, 2020

I am no longer a Java user and cannot speak to the current validity of this code snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.