diff --git a/build.gradle b/build.gradle index 51cb668740..792331db16 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,9 @@ apply plugin: QuasarPlugin apply plugin: 'com.github.ben-manes.versions' allprojects { + apply plugin: 'java' + apply plugin: 'jacoco' + sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -16,6 +19,23 @@ allprojects { } } +subprojects { + dependencies { + testCompile 'junit:junit:4.12' + } + + jacocoTestReport { + additionalSourceDirs = files(sourceSets.main.allSource.srcDirs) + sourceDirectories = files(sourceSets.main.allSource.srcDirs) + classDirectories = files(sourceSets.main.output) + reports { + html.enabled = true + xml.enabled = true + csv.enabled = false + } + } +} + buildscript { ext.kotlin_version = '1.0.3' ext.quasar_version = '0.7.5' @@ -166,3 +186,24 @@ applicationDistribution.into("bin") { from(getTraderDemo) fileMode = 0755 } + +task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) { + dependsOn = subprojects.test + additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs) + sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs) + classDirectories = files(subprojects.sourceSets.main.output) + executionData = files(subprojects.jacocoTestReport.executionData) + reports { + html.enabled = true + xml.enabled = true + csv.enabled = false + } + onlyIf = { + true + } + doFirst { + executionData = files(executionData.findAll { + it.exists() + }) + } +} \ No newline at end of file diff --git a/core/src/main/kotlin/com/r3corda/core/Utils.kt b/core/src/main/kotlin/com/r3corda/core/Utils.kt index ba6edf8d29..e8ae67b2c9 100644 --- a/core/src/main/kotlin/com/r3corda/core/Utils.kt +++ b/core/src/main/kotlin/com/r3corda/core/Utils.kt @@ -114,7 +114,7 @@ fun Iterable.noneOrSingle(): T? { // An alias that can sometimes make code clearer to read. val RunOnCallerThread = MoreExecutors.directExecutor() -inline fun logElapsedTime(label: String, logger: Logger? = null, body: () -> T): T { +fun logElapsedTime(label: String, logger: Logger? = null, body: () -> T): T { val now = System.currentTimeMillis() val r = body() val elapsed = System.currentTimeMillis() - now