如何使用 Buildship 在 Eclipse 中更改 Gradle 版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32032010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change Gradle version in Eclipse using Buildship?
提问by Evandro Pomatti
I am running Eclipse Luna SR2 with Buildship 1.0.1.
我正在使用 Buildship 1.0.1 运行 Eclipse Luna SR2。
The Gradle projects I create using the wizard are building with Gradle 2.5-rc-2, but I would like to use 2.6 which is the latest version.
我使用向导创建的 Gradle 项目是使用 Gradle 2.5-rc-2 构建的,但我想使用最新版本的 2.6。
How can I do it?
我该怎么做?
Setting the task had no effect:
设置任务没有效果:
apply plugin: 'java'
repositories {
jcenter()
}
dependencies {
testCompile 'junit:junit:4.12'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.6'
}
Solution: For some reason it is only working if I restart Eclipse after setting the version as Makoto suggested.
解决方案:出于某种原因,只有在按照 Makoto 建议设置版本后重新启动 Eclipse 时它才有效。
采纳答案by Makoto
If you want to use the wrapper, it's a simple matter of setting the gradleVersion
property:
如果要使用包装器,只需设置gradleVersion
属性即可:
task wrapper(type: Wrapper) {
gradleVersion = '2.6'
}
回答by jpmath
You can create a new Run Configuration
of type Gradle Project
running the task wrapper
. Running this run configuration should update the wrapper version without the need to restart eclipse.
您可以创建一个运行任务的新Run Configuration
类型。运行此运行配置应该会更新包装器版本,而无需重新启动 eclipse。Gradle Project
wrapper
回答by SteadyBigman
I had the same issue with different versions. The solution is to add the following task to your build file, then run gradle wrapper task in the project root folder:
我在不同版本中遇到了同样的问题。解决方案是将以下任务添加到您的构建文件中,然后在项目根文件夹中运行 gradle wrapper 任务:
task wrapper(type: Wrapper) {
gradleVersion = '2.6'
}
The reason the wrong version of wrapper was used for the build is that there was no wrapper created for the version I wanted to use.
错误版本的包装器用于构建的原因是没有为我想要使用的版本创建包装器。