如何使用 Gradle 在 Gluon 项目中设置 JUnit 测试
How to setup JUnit testing in Gluon Project with Gradle
我正在尝试在我的 Gluon JavaFX 应用程序中设置 JUnit 测试。我将 Gluon Eclipse 插件与 Gradle 和 Java 8 一起使用。
我的 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')
}
}
解决依赖没问题,但是运行宁'test'任务时,gradle抛出这样的错误:
When running gradle with java 8, you must set the path to the old jdk, either with property retrolambda.oldJdk or environment variable JAVA6_HOME/JAVA7_HOME
Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip'.
我已经尝试根据 GitHub 上的 README 插件将 retrolambda 插件添加到 gradle,但目前还没有成功。有人能告诉我如何配置我的 Gluon 项目,以便我能够 运行 我的 JUnit 测试 Gradle 吗?
一些重要的补充:
对于插件版本,它说:Gluon Tools 1.0.0.201508201514
我想我忘记提到我想将 Dagger 依赖注入与 Gluon Ignite 结合使用,这在我的情况下可能是真正的问题,因为它需要 Java 8 并且可能与 javafxports 或其他东西冲突。但是,我无法完全理解所看到的各种错误消息。
我的测试是空的,但它们甚至都不是 运行,因为它之前失败了。
您的问题似乎是 retroLambda 配置 问题。如果您浏览插件的 configuration 页面,它会声明如果您没有为 JAVA6_HOME
或 JAVA7_HOME
设置环境变量,则需要显式定义 oldJdk
插件才能正常工作。
我正在尝试在我的 Gluon JavaFX 应用程序中设置 JUnit 测试。我将 Gluon Eclipse 插件与 Gradle 和 Java 8 一起使用。
我的 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')
}
}
解决依赖没问题,但是运行宁'test'任务时,gradle抛出这样的错误:
When running gradle with java 8, you must set the path to the old jdk, either with property retrolambda.oldJdk or environment variable JAVA6_HOME/JAVA7_HOME Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip'.
我已经尝试根据 GitHub 上的 README 插件将 retrolambda 插件添加到 gradle,但目前还没有成功。有人能告诉我如何配置我的 Gluon 项目,以便我能够 运行 我的 JUnit 测试 Gradle 吗?
一些重要的补充:
对于插件版本,它说:Gluon Tools 1.0.0.201508201514
我想我忘记提到我想将 Dagger 依赖注入与 Gluon Ignite 结合使用,这在我的情况下可能是真正的问题,因为它需要 Java 8 并且可能与 javafxports 或其他东西冲突。但是,我无法完全理解所看到的各种错误消息。
我的测试是空的,但它们甚至都不是 运行,因为它之前失败了。
您的问题似乎是 retroLambda 配置 问题。如果您浏览插件的 configuration 页面,它会声明如果您没有为 JAVA6_HOME
或 JAVA7_HOME
设置环境变量,则需要显式定义 oldJdk
插件才能正常工作。