Building a Kotlin + Java 9 project with Gradle

前端 未结 3 1365
刺人心
刺人心 2021-02-02 13:22

I\'m fairly new to Gradle (and Java 9, to be honest), and I\'m trying to use Gradle to build a simple library project that is a mix of Java 9 and Kotlin. More in detail, there i

3条回答
  •  被撕碎了的回忆
    2021-02-02 14:14

    The accepted answer did not work for me (atleast not the way it was presented), but this is what worked:

    plugins {
        id "org.jetbrains.kotlin.jvm" version "1.3.50"
    }
    
    compileKotlin {
        doFirst {
            destinationDir = compileJava.destinationDir
        }
    }
    
    jar {
        duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    }
    

    Doing it the way the accepted answer suggests led to me getting this error:

    Directory '/path/to/project/build/classes/kotlin/main' specified for property 'compileKotlinOutputClasses' does not exist.


    Gradle version: 5.6

提交回复
热议问题