diff --git a/.travis.yml b/.travis.yml index a5394330f..9395574ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,10 @@ language: java +jdk: + - oraclejdk8 + +before_install: + - export JAVA7_HOME=/usr/lib/jvm/java-7-oracle + - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle install: - TERM=dumb ./gradlew compileJava script: diff --git a/README.md b/README.md index 63438ef8a..12fa26511 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,17 @@ If you are interested in contributing to the BRJS core toolkit then the followin You may need to run `git submodule sync` and `git submodule update` when changing branches if submodules have changed. +#### Install JDK + +BRJS is written and compiled using Java 8, but we distribute it and run the tests against it using Java 7, courtesy of [retrolambda](https://github.com/orfjackal/retrolambda). Because of this, you will need to do the following: + + * Install both Java 7 and Java 8 JDKs. + * Configure `JAVA7_HOME` to point to the Java 7 JDK home directory. + * Configure `JAVA8_HOME` to point to the Java 8 JDK home directory. + * Configure `JAVA_HOME` to point to either the Java 7 or the Java 8 JDK home directory, as you prefer. + * Configure the `path` environment variable to include `$JAVA_HOME/bin`. + + #### Build a Distributable Zip From the root `brjs` source directory: diff --git a/brjs-core/build.gradle b/brjs-core/build.gradle index 5f068cdcb..7f19fbc7d 100644 --- a/brjs-core/build.gradle +++ b/brjs-core/build.gradle @@ -1,7 +1,21 @@ apply plugin: 'java' +apply plugin: 'retrolambda' apply plugin: com.caplin.gradle.plugins.CompileOnly +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath dependency('gradle-retrolambda') + } +} + +retrolambda { + javaVersion JavaVersion.VERSION_1_7 +} + sourceSets { test { java { @@ -19,6 +33,8 @@ configurations { } dependencies { + retrolambdaConfig dependency('retrolambda') + compile project(":brjs-logger") compile dependency('commons-io') compile dependency('commons-lang3') @@ -67,11 +83,7 @@ javadoc { /* info for JavaDoc options http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javadoc.html#overviewcomment */ options.overview = "${sourceSets.main.java.srcDirs.toArray()[0]}/overview-summary.html" maxMemory = "128m" -} - -javadoc { - title = "BladeRunnerJS ${buildVersion}" - classpath += project.configurations.compileOnly + executable = "$System.env.JAVA8_HOME/bin/javadoc" } task javadocZip, type:Zip, dependsOn:javadoc, { diff --git a/brjs-core/src/main/java/org/bladerunnerjs/testing/specutility/engine/NodeCommander.java b/brjs-core/src/main/java/org/bladerunnerjs/testing/specutility/engine/NodeCommander.java index 5be91570f..8868ab151 100644 --- a/brjs-core/src/main/java/org/bladerunnerjs/testing/specutility/engine/NodeCommander.java +++ b/brjs-core/src/main/java/org/bladerunnerjs/testing/specutility/engine/NodeCommander.java @@ -19,41 +19,25 @@ public NodeCommander(SpecTest specTest, N node) { } public CommanderChainer create() { - call(new Command() { - public void call() throws Exception { - node.create(); - } - }); + call(() -> node.create()); return commanderChainer; } public CommanderChainer populate() throws Exception { - call(new Command() { - public void call() throws Exception { - ((BRJSNode) node).populate(); - } - }); + call(() -> ((BRJSNode) node).populate()); return commanderChainer; } public CommanderChainer delete() { - call(new Command() { - public void call() throws Exception { - node.delete(); - } - }); + call(() -> node.delete()); return commanderChainer; } public CommanderChainer ready() { - call(new Command() { - public void call() throws Exception { - node.ready(); - } - }); + call(() -> node.ready()); return commanderChainer; } diff --git a/build.gradle b/build.gradle index 7511ef7dc..fb9591947 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,14 @@ if (project.hasProperty(overrideMajorVersionPropertyName)) { } +[ "JAVA8_HOME", "JAVA7_HOME" ].each { envName -> + def property = System.getenv()[envName] + if (property == null) + { + throw new GradleException("The environment variable '${envName} must be set for the build to work correctly, please make sure it is set. Refer to README.md for info on the dev environment setup.") + } +} + allprojects { ext { @@ -73,9 +81,15 @@ subprojects { p -> afterEvaluate { project -> if (project.plugins.hasPlugin(JavaPlugin)) { - sourceCompatibility = '1.7' - targetCompatibility = '1.7' - + if(project.name == 'brjs-core') { + sourceCompatibility = '1.8' + targetCompatibility = '1.8' + } + else { + sourceCompatibility = '1.7' + targetCompatibility = '1.7' + } + project.tasks.withType(Test) { testTask -> test { testLogging { diff --git a/dependencies.gradle b/dependencies.gradle index 849610809..73bf69031 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -20,7 +20,9 @@ ext { * 'jetty-all-server' : 'org.eclipse.jetty.aggregate:jetty-all-server:8.1.0.v20120127' */ Dependencies.putAll([ - + 'gradle-retrolambda' : 'me.tatarka:gradle-retrolambda:1.3.0', + 'retrolambda' : 'net.orfjackal.retrolambda:retrolambda:1.1.4', + 'jetty-all-server' : 'org.eclipse.jetty.aggregate:jetty-all-server:7.6.4.v20120524', /* version should be 7.x - this version uses servlet api v2.5 */ 'jsp-2.1-glassfish' : 'org.mortbay.jetty:jsp-2.1-glassfish:2.1.v20100127', 'jta' : 'javax.transaction:jta:1.1',