From c26727d7a7fb1e3ab9485a8a5a55d9bab503b4c7 Mon Sep 17 00:00:00 2001 From: James Ward Date: Tue, 6 Oct 2020 12:05:43 -0600 Subject: [PATCH] gradle updates --- build.gradle | 7 +++---- gradle/findbugs.gradle | 4 +++- gradle/junit-jupiter.gradle | 36 +++++++++++++++++++++++------------- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index afd39a4a..09683e46 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,7 @@ buildscript { } } dependencies { - classpath 'me.champeau.gradle:jmh-gradle-plugin:0.3.1' - classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M2' + classpath 'me.champeau.gradle:jmh-gradle-plugin:0.5.2' } } @@ -18,7 +17,7 @@ subprojects { apply from: "$rootProject.projectDir/gradle/jmh.gradle" apply from: "$rootProject.projectDir/gradle/checkstyle.gradle" apply from: "$rootProject.projectDir/gradle/findbugs.gradle" - apply plugin: 'com.mindviewinc.tagging' + //apply plugin: 'com.mindviewinc.tagging' } -apply from: 'gradle/subprojects.gradle' \ No newline at end of file +apply from: 'gradle/subprojects.gradle' diff --git a/gradle/findbugs.gradle b/gradle/findbugs.gradle index f7e6383b..ac628cb2 100644 --- a/gradle/findbugs.gradle +++ b/gradle/findbugs.gradle @@ -1,3 +1,4 @@ +/* apply plugin: 'findbugs' findbugs { @@ -10,4 +11,5 @@ tasks.withType(FindBugs) { xml.enabled = false html.enabled = true } -} \ No newline at end of file +} +*/ diff --git a/gradle/junit-jupiter.gradle b/gradle/junit-jupiter.gradle index ccdd4ec0..98a77843 100644 --- a/gradle/junit-jupiter.gradle +++ b/gradle/junit-jupiter.gradle @@ -1,19 +1,15 @@ import org.apache.tools.ant.util.TeeOutputStream -apply plugin: 'org.junit.platform.gradle.plugin' - -ext { - junitJupiterVersion = '5.0.0-M2' -} - dependencies { - testCompile "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" - testRuntime "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}" + testImplementation(platform('org.junit:junit-bom:5.7.0')) + testImplementation('org.junit.jupiter:junit-jupiter') } -junitPlatform { - platformVersion '1.0.0-M2' - includeClassNamePattern '.*' +test { + useJUnitPlatform() + testLogging { + events "passed", "skipped", "failed" + } } /* NEW: (REQUIRES CODE REWRITES IN BOOK AND TEST CODE) @@ -45,14 +41,28 @@ junitPlatform { JUnit 5's junitPlatformTest runs as a "javaExec" rather than a "test", so we can't hook into the before/after test behavior. */ -tasks.findByPath(":$name:junitPlatformTest").configure { +tasks.findByPath(":$name:test").configure { File testDir = file("tests") if(testDir.exists()) { File outFile = new File(testDir, 'report.txt') + + Writer taskOutput + doFirst { - standardOutput = new TeeOutputStream(new FileOutputStream(outFile, true), System.out) + taskOutput = project.file(outFile).newWriter() } + + testLogging.showStandardStreams = true + + onOutput { descriptor, event -> + taskOutput.append(event.message) + } + doLast { + // WARNING: if the task fails, this won't be executed and the file remains open. + // The memory cache version doesn't have this problem. + taskOutput.close() + if(outFile.size() == 0) outFile.delete() else if(outFile.text.contains("0 tests found"))