Skip to content

Commit

Permalink
Merge pull request #475 from BladeRunnerJS/java8-support
Browse files Browse the repository at this point in the history
Java8 support
  • Loading branch information
dchambers committed Apr 2, 2014
2 parents fc2d898 + 4203ce8 commit a6bfd8b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 29 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 17 additions & 5 deletions brjs-core/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -19,6 +33,8 @@ configurations {
}

dependencies {
retrolambdaConfig dependency('retrolambda')

compile project(":brjs-logger")
compile dependency('commons-io')
compile dependency('commons-lang3')
Expand Down Expand Up @@ -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, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
20 changes: 17 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit a6bfd8b

Please sign in to comment.