1

I am trying to setup JUnit testing in my Gluon JavaFX Application. I am using the Gluon Eclipse Plugin with Gradle and Java 8.

My build.gradle file looks like this:

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')
    }
}

Resolving the dependency is no problem, but when running the 'test' task, gradle throws an error like this:

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'.

I already tried to add the retrolambda plugin to gradle according to the plugin's README on GitHub, but it doesn't work so far. Could someone tell me what to do to configure my Gluon project so that I am able to run my JUnit tests with Gradle?

Some important addidtions:
For the plugin version it says: Gluon Tools 1.0.0.201508201514
I think I fogot to mention that I want to use Dagger dependency injection with Gluon Ignite which might be the real problem in my case as it requires Java 8 and might conflict with javafxports or something else. However, I'm not able to make full sense of the various error messages I've seen. My tests are empty, but they aren't even run, because it fails before.

MannikJ
  • 301
  • 1
  • 15
  • Which version of Eclipse Gluon plugin are you using? I cannot replicate your issue with a v2.0 plugin. If you are using the same, can you add details about your tests? – ItachiUchiha Mar 01 '16 at 18:14
  • I added some further information to the end of the question. – MannikJ Mar 02 '16 at 09:31
  • 1
    I think the problem is more related to the way you configure retroLambda plugin. If you go through the [configuration](https://github.com/evant/gradle-retrolambda/blob/master/README.md#configuration) details, you will find that you need to define `oldJdk`. Have you defined it? – ItachiUchiha Mar 02 '16 at 10:04
  • Hey, after watching a basic tutorial about gradle and groovy scripting and your hint I got it working by adding: `retrolambda {oldJdk 'C:/Program Files/Java/jdk1.7.0_79'}` Setting JAVA7_HOME variable didn't do the trick. Is there a better solution then to add a specific path to the build file? I would rather like to have the build file independent from the developer's system – MannikJ Mar 02 '16 at 10:16
  • It should have worked, I am afraid if it doesn't work with environment variables, you will have to live with hard coding the value for now and look for better solution later. – ItachiUchiha Mar 02 '16 at 10:17
  • Ok, it's always the same: You're tinkering around for days and nothing works. Then someone comes around to point your attention at things you already tried and suddenly everything's fine - embarrassing...The configuration via JAVA7_HOME variable now also works. Maybe a restart of eclipse did it. I could now do it without any configuration in the build script but altered it to: `retrolambda { oldJdk System.getenv("JAVA7_HOME") }` Is it possible to configure an online repository instead of any local path? – MannikJ Mar 02 '16 at 10:37

1 Answers1

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.

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176