如何使用Gradle在Gluon项目中设置JUnit测试

时间:2016-02-26 15:52:51

标签: eclipse gradle java-8 junit4 gluon

我正在尝试在我的Gluon JavaFX应用程序中设置JUnit测试。我正在使用带有Gradle和Java 8的Gluon Eclipse插件。

我的build.gradle文件如下所示:

buildscript {
    repositories {
        jcenter()   
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b10'
    }    
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
}

dependencies {
        compile 'com.gluonhq:ignite-dagger:1.0.0'
        compile 'org.elasticsearch:elasticsearch:1.6.0'
        compile 'ch.qos.logback:logback-classic:1.1.5'
        testCompile 'junit:junit:4.12'
}

mainClassName = 'com.me.MyApplication'

jfxmobile {
    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
    }
}

解决依赖关系没问题,但是在运行'测试'任务,gradle抛出这样的错误:

  

使用java 8运行gradle时,必须使用属性retrolambda.oldJdk或环境变量JAVA6_HOME / JAVA7_HOME设置旧jdk的路径   无法使用Gradle分发' https://services.gradle.org/distributions/gradle-2.2.1-all.zip'。

执行构建

我已经尝试根据GitHub上的插件#{3}}将retrolambda插件添加到gradle中,但到目前为止它还没有工作。有人可以告诉我如何配置我的Gluon项目,以便我能够使用Gradle运行我的JUnit测试吗?

一些重要的补充:
对于插件版本,它说:胶子工具1.0.0.201508201514
我想我提到我想要使用Dagger依赖注入与Gluon Ignite,这可能是我的情况下的真正问题,因为它需要Java 8并且可能与javafxports或其他东西冲突。但是,我无法充分了解我所看到的各种错误消息。 我的测试是空的,但它们甚至都没有运行,因为它之前失败了。

1 个答案:

答案 0 :(得分:2)

Your problem seems like a retroLambda configuration issue. If you go through the configuration page for the plugin, it states that if you don't have an environment variable set for JAVA6_HOME or JAVA7_HOME than you need to explicitly define oldJdk for the plugin to work properly.