Gradle Eclipse不工作

时间:2015-02-22 11:53:08

标签: eclipse gradle gradle-plugin

我的build.gradle脚本:

apply plugin: 'groovy'
apply plugin: 'eclipse'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

dependencies {
    compile (
        'org.apache.camel:camel-core:2.14.1',
        'org.apache.camel:camel-mail:2.14.1'
    )
}

当我运行gradle eclipse时,我看到了:

:myapp:eclipseClasspath
:myapp:eclipseJdt
:myapp:eclipseProject
:myapp:eclipse

BUILD SUCCESSFUL

Total time: 3.694 secs

当我运行gradle clean build时,我收到类似的BUILD SUCCESSFUL消息。但是当我在Eclipse中刷新项目时,我看不到包含Camel Core或Camel Mail的Referenced Libraries文件夹,而是在Problems选项卡下我看到3个问题:

  • 项目'myapp'缺少必需的库:'D:\ workspace \ myapp \ unresolved dependency - org.apache.camel camel-core 2.14.1'
  • 项目'myapp'缺少必需的库:'D:\ workspace \ myapp \ unresolved dependency - org.apache.camel camel-mail 2.14.1'
  • 在解决构建路径错误之前无法构建项目

这里发生了什么?在一个或许有点相关的说明中,我在Eclipse Juno上,进入Properties>> Java>>编译器,我似乎没有选择将我的Eclipse Java编译器设置为1.8,只有1.7。也许我的Eclipse实例太旧了,无法处理Java 8?

1 个答案:

答案 0 :(得分:1)

如果这是您的完整构建脚本,那么您将缺少存储库定义(从哪里获取工件)。尝试添加:

repositories {
   mavenCentral()
}

如果您需要添加自定义网址,请repositories {} backing class