Skip to content

Instantly share code, notes, and snippets.

@AbrarSyed
Last active January 18, 2018 00:36
Show Gist options
  • Select an option

  • Save AbrarSyed/9440192 to your computer and use it in GitHub Desktop.

Select an option

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 files = [
'rt.jar',
'charsets.jar',
'deploy.jar',
'javaws.jar',
'jce.ar',
'jsse.jar',
'management-agent.jar',
'plugin.jar',
'resources.jar'
]
def base6 = "/opt/java6/jre/lib/"
def path6 = files.collect({ return base6 + it }).join(File.pathSeparator)
tasks.withType(Compile) { task ->
if (task.targetCompatibility == '1.6')
{
task.options.fork = true;
task.options.bootClasspath = path6
}
}
tasks.withType(JavaCompile) { task ->
if (task.targetCompatibility == '1.6')
{
task.options.fork = true;
task.options.bootClasspath = path6
}
}
}
}
@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