简体   繁体   English

无法在Eclipse中执行Gradle构建

[英]Cannot execute gradle build in eclipse

I create new Gradle project in Eclipse Luna but when I try to execute Gradle build through the Gradle plugin in eclipse I get an error: 我在Eclipse Luna创建了新的Gradle项目,但是当我尝试通过Eclipse Luna的Gradle插件执行Gradle构建时,出现错误:

FAILURE: Build failed with an exception. 失败:构建失败,发生异常。

  • What went wrong: Execution failed for task ':compileJava'. 出了什么问题:任务':compileJava'的执行失败。

    Cannot find System Java Compiler. 找不到系统Java编译器。 Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory. 确保已安装JDK(而不仅仅是JRE),并将JAVA_HOME系统变量配置为指向相应的目录。

The thing is JAVA_HOME is setted and running gradle build through the cmd is OK . 事情是JAVA_HOME ,并通过cmd运行gradle buildOK I create two files in the same directory where build.gradle is located, there are: gradle.properties : 我在build.gradle所在的同一目录中创建两个文件,它们是: gradle.properties

org.gradle.java.home=C:/Program Files/Java/jdk1.7.0_60

and local.properties : local.properties

org.gradle.java.home=C:/Program Files/Java/jdk1.7.0_60

UPD: When I try to delete and re-import that project, it works fine. UPD:当我尝试删除并重新导入该项目时,它工作正常。 When I click to the build model button it's also ok. 当我单击build model按钮时,也没问题。 But when I'm trying to execute build task, it doesn't workd. 但是,当我尝试执行构建任务时,它不起作用。

Here is how this issue can be fixed. 这是解决此问题的方法。

  1. Go to Eclipse-Luna menu Windows>Prefernces 转到Eclipse-Luna菜单Windows>首选项
  2. Select Gradle>Arguments 选择Gradle>参数
  3. Update Workspace JRE : to point to a jdk instead of jre as Gradle requires jdk for code compilation. 更新工作区JRE:指向jdk而不是jre,因为Gradle需要jdk进行代码编译。

在此处输入图片说明

Here is where to update you installed JRE in eclipse. 这是在Eclipse中更新安装的JRE的位置。 As you can see I have added a jdk. 如您所见,我添加了一个jdk。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM