Merge "Make doclava compatible with both JDK 8 and 11."
diff --git a/build.gradle b/build.gradle
index 3096e0e..7cd0f09 100644
--- a/build.gradle
+++ b/build.gradle
@@ -22,13 +22,6 @@
group = 'com.android'
version = '1.0.6'
-def currentJvmVersion = org.gradle.api.JavaVersion.current()
-if (currentJvmVersion.getMajorVersion() != "8") {
- throw new Exception("Unsupported java version '" + currentJvmVersion.toString() + "'. Please install java 8.\n" +
-"\n" +
-"If you have already installed java 8, you can instruct Gradle to use it by setting the environment variable JAVA_HOME equal to its file path.")
-}
-
/*
* With the build server you are given two env variables:
* 1. The OUT_DIR is a temporary directory you can use to put things during the build.
@@ -85,7 +78,17 @@
testCompile 'junit:junit:4.12'
// tools.jar required for com.sun.javadoc
- compile files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs())
+ def currentJvmVersion = org.gradle.api.JavaVersion.current()
+ def toolsJar;
+ if (currentJvmVersion.getMajorVersion() == "8") {
+ toolsJar = ((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs()
+ } else if (System.env.JAVA_TOOLS_JAR != null) {
+ toolsJar = System.env.JAVA_TOOLS_JAR
+ } else {
+ throw new Exception("If you are not using Java 8, JAVA_TOOLS_JAR env variable " +
+ "needs to be set to build Doclava")
+ }
+ compile files(toolsJar)
}
sourceSets {