spekframework / spek

A specification framework for Kotlin
Other
2.23k stars 180 forks source link

v2.0.16 dropped support for Java 8 #966

Open jGleitz opened 3 years ago

jGleitz commented 3 years ago

Upgrading to v2.0.16 leads to the error message below in Gradle when running in Java 8. Since v2.0.15 worked fine with Java 8, I think that this is a regression that should be fixed by correcting the Gradle metadata file of the artefacts.

> Could not resolve all files for configuration ':apis:atrium-gradle-testkit-fluent-en:testRuntimeClasspath'.
   > Could not resolve org.spekframework.spek2:spek-runner-junit5:2.0.16.
     Required by:
         project :apis:atrium-gradle-testkit-fluent-en
      > No matching variant of org.spekframework.spek2:spek-runner-junit5:2.0.16 was found. The consumer was configured to find a runtime of a library compatible with Java 8, 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 org.spekframework.spek2:spek-runner-junit5:2.0.16 declares a library, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
          - Variant 'runtimeElements' capability org.spekframework.spek2:spek-runner-junit5:2.0.16 declares a runtime of a library, packaged as a jar, 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 11 and the consumer needed a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
   > Could not find spek:spek-dsl:2.0.16.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/spek/spek-dsl/2.0.16/spek-dsl-2.0.16.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :apis:atrium-gradle-testkit-fluent-en > org.spekframework.spek2:spek-runtime-jvm:2.0.16
   > Could not resolve org.spekframework.spek2:spek-runner-junit5:2.0.12.
     Required by:
         project :apis:atrium-gradle-testkit-fluent-en > project :api-spec > ch.tutteli.atrium:atrium-specs:0.16.0
      > No matching variant of org.spekframework.spek2:spek-runner-junit5:2.0.16 was found. The consumer was configured to find a runtime of a library compatible with Java 8, 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 org.spekframework.spek2:spek-runner-junit5:2.0.16 declares a library, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
          - Variant 'runtimeElements' capability org.spekframework.spek2:spek-runner-junit5:2.0.16 declares a runtime of a library, packaged as a jar, 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 11 and the consumer needed a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
jGleitz commented 3 years ago

In #964 @raniejade mentioned that v2.0.15 was published without Gradle metadata. I think this regression was introduced by adding this metadata.

raniejade commented 3 years ago

Yeah, unintended side-effect. A solution perhaps is to explicitly tell the kotlin plugin the JDK target. @sh-soltanpour are you able to look at this? Thanks for the report @jGleitz!

raniejade commented 3 years ago

Looks like we need to set org.gradle.jvm.version attribute to 8. Also apparently as a workaround you can do this https://docs.gradle.org/current/userguide/component_metadata_rules.html. Apologies for the delay, I'm a bit busy with my personal life atm.

raniejade commented 3 years ago

Attributes can be set via https://docs.gradle.org/current/userguide/variant_attributes.html#sec:declaring_attributes.