https://kotlinlang.org logo
Title
g

Gizmo

01/30/2018, 1:47 PM
Hi Everyone! I'm trying to convert my gradle buildscript to kotlin. This was my original script: https://github.com/sandrobraendli/ExcelTaImport/blob/master/build.gradle And this is what I came up with so far: https://github.com/sandrobraendli/ExcelTaImport/blob/gradle-kotlin/build.gradle.kts The problem is, when I try to compile, I get the following error (multiple times): e: C:\Users\sbraendli_adm.ZSO\IdeaProjects\ExcelTaImport\src\main\java\io\braendli\importer\Importer.kt: (33, 45): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: @InlineOnly public inline fun <T : Closeable?, R> ???.use(block: (???) -> ???): ??? defined in kotlin.io From what I understand, this is because the default jvmTarget for Kotlin is 1.6. Despite some intense googling and trying, I couldn't make the error go away. I hope someone can help.
c

Czar

01/30/2018, 2:02 PM
You have wrong dependency, instead of
compile(kotlin("stdlib"))
you need
compile(kotlin("stdlib-jdk8"))
g

Gizmo

01/30/2018, 2:38 PM
This worked, thank you very much.
However, I don' understand how this is the same as what I did in the original gradle script. https://github.com/sandrobraendli/ExcelTaImport/blob/a03893603f4d5d2bff62e7aaa8b2498a3357b112/build.gradle
c

Clint Checketts

01/31/2018, 12:11 AM
g

Gizmo

01/31/2018, 7:13 AM
You are right So I guess this wasn't needed:
compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}