Skip to content

Commit

Permalink
Setup java8/java9
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Sep 27, 2017
1 parent 189b10e commit 5df53c3
Show file tree
Hide file tree
Showing 24 changed files with 1,224 additions and 22 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=1.10.0-SNAPSHOT
version=2.0.0-SNAPSHOT
group=org.kordamp.ikonli
sourceCompatibility=1.7
targetCompatibility=1.7
Expand Down
28 changes: 28 additions & 0 deletions gradle/jdks.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// taken from https://github.com/melix/mrjar-gradle/blob/master/jdks.gradle
// (c) Cedric Champeau

String compat(String src) {
if (src.contains('.')) {
src.substring(src.lastIndexOf('.') + 1)
} else {
src
}
}

// this will configure the java compile tasks with the appropriate JDK
project.afterEvaluate {
tasks.withType(JavaCompile) {
def version = compat(sourceCompatibility)
def jdkHome = System.getenv("JAVA_${version}")
if (!jdkHome) {
println "Warning: Please set path to JDK ${version} using environment variable JAVA_${version}"
println 'Falling back to current JDK'
} else {
options.fork = true
options.forkOptions.javaHome = file(jdkHome)
doFirst {
println "$name compiles using JDK $version"
}
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip
33 changes: 18 additions & 15 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
File subdir = new File(rootDir, "subprojects")
rootProject.name = 'ikonli'

def includeProject = { String projectDirName, String projectName ->
File baseDir = new File(settingsDir, projectDirName)
File projectDir = new File(baseDir, projectName)
String buildFileName = "${projectName}.gradle"

assert projectDir.isDirectory()
assert new File(projectDir, buildFileName).isFile()

include projectName
project(":${projectName}").projectDir = projectDir
project(":${projectName}").buildFileName = buildFileName
}

File subdir = new File(rootDir, 'subprojects')
subdir.eachDir { dir ->
File buildFile = new File(dir, "${dir.name}.gradle")
if (buildFile.exists()) {
include "subprojects/${dir.name}"
includeProject 'subprojects', dir.name
}
}

rootProject.name = 'ikonli'
rootProject.children.each { project ->
int slash = project.name.indexOf('/')
String fileBaseName = project.name[(slash + 1)..-1]
String projectDirName = project.name
project.name = fileBaseName
project.projectDir = new File(settingsDir, projectDirName)
project.buildFileName = "${fileBaseName}.gradle"
assert project.projectDir.isDirectory()
assert project.buildFile.isFile()
}
}
103 changes: 99 additions & 4 deletions subprojects/ikonli-javafx/ikonli-javafx.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,102 @@
apply from: rootProject.file('gradle/javafx.gradle')
apply plugin: 'java-library'
apply from: rootProject.file('gradle/jdks.gradle')

sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
}
java8 {
java {
srcDirs = ['src/main/java8']
}
}
java9 {
java {
srcDirs = ['src/main/java9']
}
}
java8Test {
java {
srcDirs = ['src/test/java8']
}
}
java9Test {
java {
srcDirs = ['src/test/java9']
}
}
}

dependencies {
compileOnly project.files(project.jfxrtLocation)
testCompileOnly project.files(project.jfxrtLocation)
compile project(':ikonli-core')
}
java8Implementation project(':ikonli-core')
java9Implementation project(':ikonli-core')
java8Implementation files(sourceSets.main.output.classesDirs) { builtBy compileJava }
java9Implementation files(sourceSets.main.output.classesDirs) { builtBy compileJava }

java8TestImplementation 'junit:junit:4.12',
project(':ikonli-core'),
files(sourceSets.main.output.classesDirs),
files(sourceSets.java8.output.classesDirs)
java9TestImplementation 'junit:junit:4.12',
project(':ikonli-core'),
files(sourceSets.main.output.classesDirs),
files(sourceSets.java9.output.classesDirs)
}

compileJava {
sourceCompatibility = 8
targetCompatibility = 8
}

compileJava8Java {
sourceCompatibility = 8
targetCompatibility = 8
}

compileJava9Java {
sourceCompatibility = 9
targetCompatibility = 9
}

jar {
into('META-INF/versions/9') {
from sourceSets.java9.output
}
into('/') {
from sourceSets.java8.output
}
manifest {
attributes(
'Multi-Release': 'true'
)
}
}

task testJava8(type: Test, dependsOn: java8Classes) {
testClassesDirs = sourceSets.java8.output.classesDirs
classpath = sourceSets.java8Test.runtimeClasspath
}

task testJava8Report(type: TestReport, dependsOn: testJava8) {
destinationDir = file("${buildDir}/reports/tests/testJava8")
reportOn testJava8.binResultsDir
}

testJava8.finalizedBy testJava8Report
check.dependsOn testJava8

task testJava9(type: Test, dependsOn: java9Classes) {
testClassesDirs = sourceSets.java9Test.output.classesDirs
classpath = sourceSets.java9Test.runtimeClasspath
}

task testJava9Report(type: TestReport, dependsOn: testJava9) {
destinationDir = file("${buildDir}/reports/tests/testJava9")
reportOn testJava9.binResultsDir
}

testJava9.finalizedBy testJava9Report
check.dependsOn testJava9
Loading

0 comments on commit 5df53c3

Please sign in to comment.