Skip to content

JVM compatibility error in buildSrc #76

Closed
@aSemy

Description

@aSemy

Hi, I've just updated to v6.1.1 and I'm getting an error

./gradlew version -q

FAILURE: Build failed with an exception.

* What went wrong:
java.lang.UnsupportedClassVersionError: me/qoomon/gradle/gitversioning/GitVersioningPlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
> me/qoomon/gradle/gitversioning/GitVersioningPlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I see this changed in this commit: 4a7d963

I've set the plugin in my buildSrc/build.gradle.kts

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
  idea
  `kotlin-dsl`
  kotlin("jvm") version "1.6.21"
}


dependencies {
  // ...

  implementation("me.qoomon:gradle-git-versioning-plugin:6.1.1")
}


tasks.withType<KotlinCompile>().configureEach {

  kotlinOptions {
    jvmTarget = "11"
    apiVersion = "1.6"
    languageVersion = "1.6"
  }
}

kotlin {
  jvmToolchain {
    (this as JavaToolchainSpec).languageVersion.set(
        JavaLanguageVersion.of("11")
    )
  }

  kotlinDslPluginOptions {
    jvmTarget.set("11")
  }
}

I've set similar options for the subprojects that have the Kotlin JVM plugin.

I'm not quite sure what's wrong. I've tried a few options.

I think perhaps the best thing to do is for Git Versioning Plugin to set its JVM target to 1.8, so while the plugin requires and is written with 11, it produces class files that are compatible with 1.8.

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_1_8

I'll keep investigating. I'm making this ticket in case there's something I've missed.

Update: it looks like this issue gradle/gradle#18935. Even though I specify 11 in buildSrc/build.gradle.kts it isn't acknowledged, because Gradle uses an embedded version of Kotlin that's bugged. It might be fixed in Gradle 7.5?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions