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

Cannot run ./gradlew on cloned repo #2529

Closed
mgroth0 opened this issue Feb 1, 2024 · 3 comments
Closed

Cannot run ./gradlew on cloned repo #2529

mgroth0 opened this issue Feb 1, 2024 · 3 comments

Comments

@mgroth0
Copy link

mgroth0 commented Feb 1, 2024

Expected Behavior

Cloned project should run ./gradlew without error.

Observed Behavior

After cloning and using ./gradlew, I see this error:

Ktlint_dokka_gradle has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 64.0

I figure my gradle jvm version is wrong. The contribution docs mention setting the project language level to 8. So I tried a new command:

./gradlew -Dorg.gradle.java.home=/Users/matthewgroth/Library/Java/JavaVirtualMachines/corretto-1.8.0_402/Contents/Home/

But this just leads to a different error:

> Could not determine the dependencies of null.
   > Could not resolve all task dependencies for configuration ':ktlint-api-consumer:classpath'.
      > Could not resolve project :build-logic.
        Required by:
            project :ktlint-api-consumer
         > No matching variant of project :build-logic was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.5' but:
             - Variant 'apiElements' capability :build-logic:unspecified declares a library, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.5')
             - Variant 'mainSourceElements' capability :build-logic:unspecified declares a component, and its dependencies declared externally:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about its elements (required them packaged as a jar)
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.5')
                     - Doesn't say anything about its usage (required runtime)
             - Variant 'runtimeElements' capability :build-logic:unspecified declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.5')
             - Variant 'testResultsElementsForTest' capability :build-logic:unspecified:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about its elements (required them packaged as a jar)
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.5')
                     - Doesn't say anything about its usage (required runtime)

Steps to Reproduce

  1. Clone library
  2. Run ./gradlew

Your Environment

  • Cloned master branch at 4fd9d0b
  • My default gradle jvm is temurin-20.0.2
@Goooler
Copy link
Contributor

Goooler commented Feb 2, 2024

Install JDK 21 and try again.

@paul-dingemans
Copy link
Collaborator

And, if you have multiple version of java installed, please make sure that java 17+ is set as active version when invoking ./gradlew.

@mgroth0
Copy link
Author

mgroth0 commented Feb 5, 2024

It seems only jdk 21 works, not 20.

@mgroth0 mgroth0 closed this as completed Feb 5, 2024
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

3 participants