kazurayam / selenium-webdriver-java

Examples of the O'Reilly book "Hands-On Selenium WebDriver with Java"
https://oreil.ly/1E7CX
Apache License 2.0
0 stars 0 forks source link

In the master branch, could not run `gradle build` with JDK11 #1

Closed kazurayam closed 10 months ago

kazurayam commented 10 months ago

I had JDK11 and Gradle 6.4.1 installed:

$ java -version
openjdk version "11.0.9.1" 2020-11-04 LTS
OpenJDK Runtime Environment Corretto-11.0.9.12.1 (build 11.0.9.1+12-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.9.12.1 (build 11.0.9.1+12-LTS, mixed mode)

$ gradle -version

------------------------------------------------------------
Gradle 6.4.1
------------------------------------------------------------

Build time:   2020-05-15 19:43:40 UTC
Revision:     1a04183c502614b5c80e33d603074e0b4a2777c5

Kotlin:       1.3.71
Groovy:       2.5.10
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          11.0.9.1 (Amazon.com Inc. 11.0.9.1+12-LTS)
OS:           Mac OS X 10.16 x86_64

I cloned out the master branch https://github.com/kazurayam/selenium-webdriver-java , and just tried to build the project

$ gradle build

Then I got the following error:

$ gradle build

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':selenium-webdriver-junit4'.
> Could not resolve all artifacts for configuration ':selenium-webdriver-junit4:classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.1.4.
     Required by:
         project :selenium-webdriver-junit4 > org.springframework.boot:org.springframework.boot.gradle.plugin:3.1.4
      > The consumer was configured to find a runtime of a component compatible with Java 11, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of org.springframework.boot:spring-boot-gradle-plugin:3.1.4:
          - javadocElements
          - sourcesElements
        All of them match the consumer attributes:
          - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.4 declares a runtime of a component, and its dependencies declared externally:
              - Unmatched attributes:
                  - Provides documentation but the consumer didn't ask for it
                  - Provides javadocs but the consumer didn't ask for it
                  - 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)
                  - Provides release status but the consumer didn't ask for it
          - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.4 declares a runtime of a component, and its dependencies declared externally:
              - Unmatched attributes:
                  - Provides documentation but the consumer didn't ask for it
                  - Provides sources but the consumer didn't ask for it
                  - 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)
                  - Provides release status but the consumer didn't ask for it
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.4 declares a component, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 11
          - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.4 declares a runtime of a component, 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 11

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
kazurayam commented 10 months ago

I noticed that the project requires JDK17 as of the tag 1.3.0.

So I changed JDK to 17 using the SDKMAN! tool:

$ sdk install java 17.0.8-amzn

I needed to reboot my Mac to let the environment variable JAVA_HOME to point the JDK 17 binary

$ java -version
openjdk version "17.0.8" 2023-07-18 LTS
OpenJDK Runtime Environment Corretto-17.0.8.7.1 (build 17.0.8+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.8.7.1 (build 17.0.8+7-LTS, mixed mode, sharing)

Then I tried building the project again.

Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/kazuakiurayama/github/selenium-webdriver-java/selenium-webdriver-junit4/build.gradle' line: 4

* What went wrong:
An exception occurred applying plugin request [id: 'org.springframework.boot', version: '3.1.4']
> Failed to apply plugin [id 'org.springframework.boot']
   > Spring Boot plugin requires Gradle 7.x (7.4 or later). The current version is Gradle 6.4.1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s

The messages changed. This means that changing JDK version to 17 was successful. The gradle build now runs. So this issue should be closed.

Though there is another problem. I will follow in another issue.