Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.1.1 not working if project targets at Java 8 #749

Closed
jeffawx opened this issue Aug 1, 2022 · 2 comments
Closed

Version 3.1.1 not working if project targets at Java 8 #749

jeffawx opened this issue Aug 1, 2022 · 2 comments

Comments

@jeffawx
Copy link

jeffawx commented Aug 1, 2022

Gradle version: 7.4.2
Caffeine version: 3.1.1

java.sourceCompatibility = JavaVersion.VERSION_1_8

tasks {
    withType<KotlinCompile> {
        kotlinOptions {
            freeCompilerArgs = listOf("-Xjsr305=strict")
            jvmTarget = "1.8"
            apiVersion = "1.5"
            languageVersion = "1.5"
        }
    }
}

Build failed with error details below:

> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve com.github.ben-manes.caffeine:caffeine:3.1.1.
     Required by:
         project :
      > No matching variant of com.github.ben-manes.caffeine:caffeine:3.1.1 was found. The consumer was configured to find an API of a library compatible with Java 8, preferably in the form of class files, 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 com.github.ben-manes.caffeine:caffeine:3.1.1 declares an API of a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'javadocElements' capability com.github.ben-manes.caffeine:caffeine:3.1.1 declares a runtime of a component, 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 8)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'runtimeElements' capability com.github.ben-manes.caffeine:caffeine:3.1.1 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'sourcesElements' capability com.github.ben-manes.caffeine:caffeine:3.1.1 declares a runtime of a component, 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 8)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')

Previous version 3.1.0 works fine.

@ben-manes
Copy link
Owner

Caffeine 3.x targets Java 11, whereas 2.x targets Java 8. This was highlighted in the release notes.

It looks like the Gradle metadata now enforces the JDK version matches. The 3.1.0 release used Gradle v7.4.2 whereas 3.1.1 used v7.5. You would need to consult them on how to override that to ignore their resolution enforcement.

I hope to softly deprecate Java 8 as it has reached end-of-life in Mar 2022, with critical security updates ending in 2025. A project targeting an old JDK loses out on significant performance, ecosystem compatibility, ect. Therefore 2.x remains supported for critical bug fixes, but users are encouraged to adopt a modern JDK for the general health of their software projects.

@ben-manes
Copy link
Owner

I think you were getting a false impression of build compatibility due to #716 (comment). The shadow plugin's metadata (for jmh benchmarks) leaked into the metadata and does not supply the jvm version like the compile and runtime variants do. This allowed the selection to think prior versions were compatible when they were not. If you ran your project on jdk8 with Caffeine it would have failed unless downgrading to v2.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants