Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifiy JRE Container with gradle eclipse plugin

Even when the properties for sourceCompatibility and targetCompatibility are set to a specific JRE Version, will the classpathentry for the JRE_CONTAINER only be genarated as <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" exported="true"/>, and the default JRE-Version under "Installed JREs" in the eclipse settings doesn't always match the JRE-Version I want to use within my project.

How can I ask gradle, to set the JRE_CONTAINER to a specific version when gradle is run with gradle eclipse?


apply plugin: 'java'
apply plugin: 'eclipse'

ext {
    target = "1.5"
}

def jreContainer = 'org.eclipse.jdt.launching.JRE_CONTAINER'

if (target == '1.4' || target == '1.5') {
    jreContainer += '/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-' + target
} else if (target == '1.6' || target == '1.7') {
    jreContainer += '/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + target
}

eclipse {
    classpath {
        containers.clear()
        containers.add(jreContainer)
    }
}
like image 345
Turbokiwi Avatar asked Nov 14 '22 00:11

Turbokiwi


1 Answers

in my case it work well like below

containers.add('org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk6')

but 'jdk6' is user specific name

like image 180
gim Avatar answered Dec 28 '22 01:12

gim