mcarleio / konvert

This kotlin compiler plugin is using KSP API and generates kotlin code to map one class to another
https://mcarleio.github.io/konvert/
Apache License 2.0
93 stars 8 forks source link

Doesn't build for targets below JDK 17 #26

Open MV-GH opened 1 year ago

MV-GH commented 1 year ago

This is the error you get for using in targets below jdk 17

Execution failed for task ':kspKotlin'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve io.mcarle:konvert-api:2.3.0.
     Required by:
         project :
      > No matching variant of io.mcarle:konvert-api:2.3.0 was found. The consumer was configured to find a library for use during compile-time, compatible with Java 11, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
          - Variant 'apiElements' capability io.mcarle:konvert-api:2.3.0 declares a library for use during compile-time, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 11
          - Variant 'javadocElements' capability io.mcarle:konvert-api:2.3.0 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'runtimeElements' capability io.mcarle:konvert-api:2.3.0 declares a library for use during runtime, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 11
          - Variant 'sourcesElements' capability io.mcarle:konvert-api:2.3.0 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
mcarleio commented 1 year ago

If possible, please link me a sample project to see everything for myself. And also provide the JDK version you used. In general, Konvert is working with JDKs below 17, but the used JDK to build must be at least 17 at the moment.

MV-GH commented 1 year ago

Well its the build JDK I meant.

The sample build.gradle.kts is, the project is just default from Intellji

plugins {
    kotlin("jvm") version "1.9.10"
    id("com.google.devtools.ksp").version("1.9.10-1.0.13")
    application
}

group = "org.example"
version = "1.0-SNAPSHOT"

val konvertVersion = "2.3.0"

repositories {
    mavenCentral()
}

dependencies {
    implementation("io.mcarle:konvert-api:2.3.0")
    testImplementation(kotlin("test"))
}

dependencies{
    ksp("io.mcarle:konvert:2.3.0")
}

tasks.test {
    useJUnitPlatform()
}

kotlin {
    jvmToolchain(11)
}

application {
    mainClass.set("MainKt")
}

kotlin {
    sourceSets.main {
        kotlin.srcDir("build/generated/ksp/main/kotlin")
    }
    sourceSets.test {
        kotlin.srcDir("build/generated/ksp/test/kotlin")
    }
}
mcarleio commented 1 year ago

Hm, ok, I can reproduce this. Probably it is some feature of Gradle which I am not aware of :smile: I tried it with maven: as long as my JDK is at least 17, it is working as expected.

I will probably not go down to JDK11, as it is EOL (at least for most people not willing to pay) and now even JDK17 is not the current LTS release anymore with JDK21.