badass-jlink-plugin icon indicating copy to clipboard operation
badass-jlink-plugin copied to clipboard

JLink not working with Kotlin 1.7?

Open MagnusMG opened this issue 2 years ago • 0 comments

Starting with the example badass-jlink-example-kotlin-javafx i tried to upgrade kotlin from the 1.4.0 used in the example to the latest version, 1.7.10. It worked fine up to 1.6.21, but broke at 1.7.0, with the message 'Cannot cast org.jetbrains.kotlin.gradle.tasks.KotlinCompile_Decorated to org.gradle.api.tasks.compile.AbstractCompile'.

I had to rewrite the build.gradle file in Groovy; I could not get the Kotlin version to work. I also had to move to gradle 7.4.1 (and that worked, up to and including kotlin 1.6.21).

I do not know if this is a problem with Kotlin or in JLink.

My build.gradle:

plugins {
	// id 'org.jetbrains.kotlin.jvm' version '1.6.21'  // This works.
	id 'org.jetbrains.kotlin.jvm' version '1.7.0' // This does not work.
	id 'application'

	id 'org.openjfx.javafxplugin' version '0.0.13'
	id 'org.beryx.jlink' version '2.25.0'
}


application {
    mainModule ='test.kotlin'
    mainClass = 'org.beryx.jlink.test.kotlin.JavaFX'
}

repositories {
    mavenCentral()
}


// I did not know how to phrase this in Grrovy, so I moved it into the compileJava task. In gradle 7 'destinationDir' has been renamed 'destinationDirectory'.
//val compileKotlin: KotlinCompile by tasks
//val compileJava: JavaCompile by tasks
//compileJava.destinationDir = compileKotlin.destinationDir

compileJava {
	destinationDirectory = compileKotlin.destinationDirectory
}


javafx {
    modules = ["javafx.controls", "javafx.fxml", "javafx.web"]
}


jlink {
    launcher {
        name = "hello"
    }
    imageZip.set(project.file("${project.buildDir}/image-zip/hello-image.zip"))
}

MagnusMG avatar Aug 05 '22 10:08 MagnusMG