Skip to content

Instantly share code, notes, and snippets.

@AbrarSyed
Last active January 18, 2018 00:36
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save AbrarSyed/9440192 to your computer and use it in GitHub Desktop.
Save AbrarSyed/9440192 to your computer and use it in GitHub Desktop.
This makes gradle compile java6 stuff with the actual java 6 classpath. --- Usage: Drop this file in USER_HOME/.gradle/init.d --- You will probably want to change the path to your java6 instance.
allprojects {
afterEvaluate {
def versions = [
'1.6' : "/usr/lib/jvm/java-6-jdk/jre/lib/",
'1.7' : "/usr/lib/jvm/java-7-openjdk/jre/lib/",
//'1.7' : "C:/Program Files/java/jre7/lib", // windows example (I think)
'1.8' : "/usr/lib/jvm/java-8-openjdk/jre/lib/"
]
// convert map to classpaths
versions = versions.collectEntries { key, value ->
[key, fileTree(dir: value, include: "*.jar")]
}
def apply = { task ->
if (versions.containsKey(task.targetCompatibility))
{
task.options.fork = true;
task.options.bootstrapClasspath = versions[task.targetCompatibility]
}
}
tasks.withType(JavaCompile, apply)
}
}
@AbrarSyed
Copy link
Author

@AbrarSyed
Copy link
Author

AbrarSyed commented Jan 18, 2018

Updated to reflect API changes in Gradle 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment