指定具有gradle eclipse插件的JRE容器 [英] Specifiy JRE Container with gradle eclipse plugin

查看:281
本文介绍了指定具有gradle eclipse插件的JRE容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使将 sourceCompatibility targetCompatibility 的属性设置为特定的JRE版本, JRE_CONTAINER 只能被定义为< classpathentry kind =conpath =org.eclipse.jdt.launching.JRE_CONTAINERimported =true /> ,eclipse设置中已安装的JRE下的默认JRE版本并不总是与我要在项目中使用的JRE版本匹配。



如果您使用 gradle eclipse 运行毕业生时,如何让毕业生将JRE_CONTAINER设置为特定版本?






 应用插件:'java'
应用插件:'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)
}
}
/ pre>

解决方案

在我的情况下
它可以像下面一样工作

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

但'jdk6'是用户指定的名称


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)
    }
}

解决方案

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

这篇关于指定具有gradle eclipse插件的JRE容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆