指定具有gradle eclipse插件的JRE容器 [英] Specifiy JRE Container with gradle eclipse plugin
问题描述
即使将 sourceCompatibility
和 targetCompatibility
的属性设置为特定的JRE版本, JRE_CONTAINER
只能被定义为< classpathentry kind =conpath =org.eclipse.jdt.launching.JRE_CONTAINERimported =true />
,eclipse设置中已安装的JRE下的默认JRE版本并不总是与我要在项目中使用的JRE版本匹配。
如果您使用 gradle eclipse
运行毕业生时,如何让毕业生将JRE_CONTAINER设置为特定版本?
应用插件:'java'
/ pre>
应用插件:'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)
}
}
解决方案在我的情况下
它可以像下面一样工作containers.add('org.eclipse.jdt.launching.JRE_CONTAINER / org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType / jdk6')
但'jdk6'是用户指定的名称
Even when the properties for
sourceCompatibility
andtargetCompatibility
are set to a specific JRE Version, will the classpathentry for theJRE_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屋!