0

I have tried various build.gradle.kts configs but I can't get rid of this error when building the project:

Execution failed for task ':compileKotlinJvm'.
> 'compileJava' task (current target is 11) and 'compileKotlinJvm' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

It seems similar to this issue but in my case it's not an android project and I don't know how to apply that in my case.

Here is my build.gradle.kts:

import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
    kotlin("multiplatform") version "1.9.0"
    id("org.jetbrains.compose") version "1.4.3"
    id("io.realm.kotlin") version "1.7.1"
}


group = "foo"
version = "1.0-SNAPSHOT"

repositories {
    google()
    mavenCentral()
    maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
    maven("https://jitpack.io") //github
}

kotlin {

    jvmToolchain(11)

    jvm {
        compilations.all {
            kotlinOptions.jvmTarget = "11"
        }

        withJava()
    }
    sourceSets {

        commonMain {
            dependencies {
                implementation("com.google.code.gson:gson:2.10.1")

                implementation("org.jetbrains.compose.material:material-icons-extended:+") // Add to use coroutines with the SDK
                implementation("com.github.lgooddatepicker:LGoodDatePicker:11.2.1")

                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") // Add to use coroutines with the SDK
                implementation("io.realm.kotlin:library-base:1.7.0") // Add to only use the local database
                implementation("io.realm.kotlin:library-sync:1.7.0") // Add to use Device Sync

                implementation("ch.astorm:jotlmsg:2.0")
                implementation("org.eclipse.swt:org.eclipse.swt.win32.win32.x86_64:4.3")
                implementation("javax.mail:javax.mail-api:1.6.2")
                implementation("com.sun.mail:javax.mail:1.6.2")

                implementation("org.odftoolkit:odfdom-java:1.0.0-BETA1")
                implementation("fr.opensagres.xdocreport:fr.opensagres.poi.xwpf.converter.pdf:2.0.4")

            }
        }

        val jvmMain by getting {
            dependencies {
                implementation(compose.desktop.currentOs)
                implementation("org.apache.pdfbox:pdfbox:2.0.28")
                implementation(kotlin("reflect"))
            }
        }
        val jvmTest by getting {
            dependencies {
                implementation(kotlin("test")) // This brings all the platform dependencies automatically
            }
        }

    }
}

compose.desktop {
    application {
        mainClass = "MainKt"
        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "fooSoft"
            packageVersion = "1.0.0"
        }
    }
}

my gradle version: 8.0

Concerning the Java version, please note that I don't want to target less than version 11.

Osman
  • 571
  • 7
  • 19
  • If you're using IntelliJ, try setting the right Java version from File -> Project Structure -> Project -> SDK (-> Add SDK if you haven't got the version you want). – Serge Sep 01 '23 at 21:04

0 Answers0