1

When I'm going to compile a repository it seems I must guess which version of Java is intended. For example, if I want to compile elasticsearch I read the readme and execute ./gradlew assemble. Eventually the build fails because I have Java8 and it requires Java11. It is a simple change, but is there a way for me to ask gradle (or maven, when applicable) for the version of Java before I start to compile?

How does developer tools deal with this? They can't possibly just try random versions of JDK until something works. Is it always manual?

  • You could always look into the gradle file and check if it specifies a language version. That would be a good indicator. Aside from that, no, there is no automated way to deal with this. –  Jul 27 '20 at 15:45

1 Answers1

0

You generally look at source and target for maven-compiler-plugin in Maven so you should be able to look at that:

Specify JDK for Maven to use.

And as stated, JDK is backwards-compatible so you can compile with the latest JDK. Maven uses the JAVA_HOME variable by the way.

Bandy
  • 161
  • 12
  • OP specifically asked about gradle, not maven, but the gist of this still applies –  Jul 27 '20 at 15:46