0

I am running into an issue with my gradle build script, build.gradle, for my java project. In this script I need to compile the application with Java 6 in order to comply with the application specifications. However, I am also using a gradle plugin that performs code analysis that needs to be run under a Java 8 JVM. What do I need to do in build.gradle or other gradle settings in order to get this plugin to use a separate Java JVM?

I need to do something like this as gradle tasks fail because the plugin is reporting a Unsupported major.minor version 52.0 Error.

Research

I have done some invesitigation and I did see the following mentioned: options.fork = true options.forkOptions.executable = System.getenv('OTHER_JAVA')

Where OTHER_JAVA is an environment variable to the other version of Java. However, I have not been able to get this to work for the plug-in and after some more research, it looks like this may be more limited to compiling with a separate version of java, not executing.
See: How do I tell Gradle to use specific JDK version?

Community
  • 1
  • 1
Andrew
  • 902
  • 1
  • 11
  • 28

1 Answers1

1

You've pretty much answered your question yourself:

it looks like this may be more limited to compiling with a separate version of java, not executing

Run Gradle under the Java 8 (that would mean specifying your JAVA_HOME as JDK 8), and fork the compiler for your app with Java 6 (as per your research).

bashnesnos
  • 816
  • 6
  • 16