0

I am trying to build with JDK 11 this project

git clone --depth 1 --branch 16.0.2 https://github.com/JetBrains/java-annotations.git

with "gradle build" command, and got the following error:

> Task :common:compileJava FAILED
error: Source option 5 is no longer supported. Use 6 or later.
error: Target option 1.5 is no longer supported. Use 1.6 or later.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':common:compileJava'.
> Compilation failed; see the compiler error output for details.

please tell me how to fix that?

  • The source code you're trying to compile is too old for the gradle version you use. Try running `./gradlew build` instead. – Alex Jun 21 '21 at 14:31
  • @Alex ./gradlew build generates the same error, but I have fixed its properties to version 5.0 before – Ekaterina Ivanova iceja.net Jun 21 '21 at 14:34
  • Even though, it generated lots of warnings about java 5 being deprecated, I just compiled your project with java 8: `/tmp/java-annotations [16.0.2|✔ ]$ JAVA_HOME=$(/usr/libexec/java_home -v 1.8) ./gradlew build`. Java 11 didn't work (because gradle 4 doesn't support it). – Alex Jun 21 '21 at 14:43
  • @Alex Unfortunately I have a task "do build this project especially with JDK 11!" for that I have modified gradlew properties to use gradle 5 instead of gradle 4.4. Could you tell me how to build this project in JDK 11? – Ekaterina Ivanova iceja.net Jun 21 '21 at 14:55
  • @Alex it builds successful when I doing "export JAVA_HOME=/home/katya/jdk1.8.0_281/" but I need strictly JDK 11 :(( – Ekaterina Ivanova iceja.net Jun 21 '21 at 15:52
  • Posting as an answer due to long code snippet. – Alex Jun 22 '21 at 10:51

1 Answers1

1

As per https://docs.gradle.org/5.0/release-notes.html#java-11-runtime-support you'll need minimal gradle version of 5.0 in order to build with JDK 11. The problem then is that the newer gradle versions drop support for java 5. Therefore, the java5 subproject will have to go. These are my code changes:

$ git diff -U0
diff --git a/build.gradle b/build.gradle
index 3201d57..bb2440e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -30 +29,0 @@ subprojects {
-project(':java5').archivesBaseName = 'annotations-java5'
@@ -33 +32 @@ project(':java8').archivesBaseName = 'annotations'
-configure([project(':java5'), project(':java8')]) {
+configure(project(':java8')) {
diff --git a/common/build.gradle b/common/build.gradle
deleted file mode 100644
index cd0e2c1..0000000
--- a/common/build.gradle
+++ /dev/null
@@ -1 +0,0 @@
-sourceCompatibility = 1.5
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index be2a0db..4888493 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -6 +6 @@ zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
diff --git a/settings.gradle b/settings.gradle
index 7774169..6a8a7cc 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -3 +3 @@ rootProject.name = 'annotations-parent'
-include 'common', 'java5', 'java8'
\ No newline at end of file
+include 'common', 'java8'
\ No newline at end of file
Alex
  • 1,313
  • 14
  • 28