Last active
March 17, 2020 16:40
-
-
Save nikolaybotev/c00d0c3267d47e5d929b6a435617c7e7 to your computer and use it in GitHub Desktop.
Gradle Build with Java 9 Modules and Kotlin Support (root project)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
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
Hi,
is this still actual?