Merge remote-tracking branch 'origin/releases/Release_2_11_3_Branch'
authorMorellThomas <morellth@yahoo.co.jp>
Thu, 7 Sep 2023 08:12:02 +0000 (10:12 +0200)
committerMorellThomas <morellth@yahoo.co.jp>
Thu, 7 Sep 2023 08:12:02 +0000 (10:12 +0200)
1  2 
build.gradle

diff --cc build.gradle
@@@ -45,10 -51,10 +51,11 @@@ plugins 
    id 'java'
    id 'application'
    id 'eclipse'
 +  id "com.diffplug.spotless" version "6.18.0" //.gradle.spotless" "3.28.0"
 +  id 'com.github.johnrengelman.shadow' version '8.1.1'        // was 4.0.3
-   id 'com.install4j.gradle' version '9.0.6'
-   id 'com.dorongold.task-tree' version '2.1.0' // only needed to display task dependency tree with  gradle task1 [task2 ...] taskTree
+   id "com.diffplug.gradle.spotless" version "3.28.0"
 -  id 'com.github.johnrengelman.shadow' version '4.0.3'
+   id 'com.install4j.gradle' version '10.0.3'
+   id 'com.dorongold.task-tree' version '2.1.1' // only needed to display task dependency tree with  gradle task1 [task2 ...] taskTree
    id 'com.palantir.git-version' version '0.13.0' apply false
  }
  
@@@ -183,7 -193,6 +194,7 @@@ ext 
    testDir = string("${jalviewDir}/${bareTestSourceDir}")
  
    classesDir = string("${jalviewDir}/${classes_dir}")
-   destinationDirectory = file(classesDir)
++  outputDir = file(classesDir)
  
    // clover
    useClover = clover.equals("true")
@@@ -1689,24 -1739,15 +1745,22 @@@ task prepare 
  }
  
  
 +// random block of dependencies
  compileJava.dependsOn prepare
  run.dependsOn compileJava
 -compileTestJava.dependsOn compileJava
 -
 -
 -
 +//run.dependsOn prepare
 +compileTestJava.dependsOn compileJava //
 +compileTestJava.dependsOn buildIndices //
 +processResources.dependsOn copyChannelResources //
 +processResources.dependsOn copyResources //
 +processResources.dependsOn createBuildProperties //
 +processResources.dependsOn copyDocs //
 +processResources.dependsOn convertMdFiles //
 +processResources.dependsOn copyHelp //
 +processResources.dependsOn buildIndices //
- //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
  test {
-   dependsOn prepare
+   group = "Verification"
+   description = "Runs all testTaskN tasks)"
  
    if (useClover) {
      dependsOn cloverClasses
@@@ -1743,10 -1878,133 +1891,134 @@@ tasks.withType(Test).matching {t -> t.g
        println("Running tests " + (useClover?"WITH":"WITHOUT") + " clover")
      }
    }
+   /* don't fail on no matching tests (so --tests will run across all testTasks) */
+   testTask.filter.setFailOnNoMatchingTests(false)
+   /* ensure the "test" task dependsOn all the testTasks */
+   test.dependsOn testTask
  }
  
+ gradle.buildFinished {
+     def allResults = rootProject.ext.testsResults
+     if (!allResults.isEmpty()) {
+         printResults allResults
+         allResults.each {r ->
+           if (r[2].resultType == TestResult.ResultType.FAILURE)
+             throw new GradleException("Failed tests!")
+         }
+     }
+ }
+ private static String colString(styler, col, colour, text) {
+   return col?"${styler[colour](text)}":text
+ }
+ private static String getSummaryLine(s, pn, tn, rt, rc, rs, rf, rsk, t, col) {
+   def colour = 'black'
+   def text = rt
+   def nocol = false
+   if (rc == 0) {
+     text = "-----"
+     nocol = true
+   } else {
+     switch(rt) {
+       case TestResult.ResultType.SUCCESS:
+         colour = 'green'
+         break;
+       case TestResult.ResultType.FAILURE:
+         colour = 'red'
+         break;
+       default:
+         nocol = true
+         break;
+     }
+   }
+   StringBuilder sb = new StringBuilder()
+   sb.append("${pn}")
+   if (tn != null)
+     sb.append(":${tn}")
+   sb.append(" results: ")
+   sb.append(colString(s, col && !nocol, colour, text))
+   sb.append(" (")
+   sb.append("${rc} tests, ")
+   sb.append(colString(s, col && rs > 0, 'green', rs))
+   sb.append(" successes, ")
+   sb.append(colString(s, col && rf > 0, 'red', rf))
+   sb.append(" failures, ")
+   sb.append("${rsk} skipped) in ${t}")
+   return sb.toString()
+ }
+ private static void printResults(allResults) {
+     // styler from https://stackoverflow.com/a/56139852
+     def styler = 'black red green yellow blue magenta cyan white'.split().toList().withIndex(30).collectEntries { key, val -> [(key) : { "\033[${val}m${it}\033[0m" }] }
+     def maxLength = 0
+     def failedTests = false
+     def summaryLines = []
+     def totalcount = 0
+     def totalsuccess = 0
+     def totalfail = 0
+     def totalskip = 0
+     def totaltime = TimeCategory.getSeconds(0)
+     // sort on project name then task name
+     allResults.sort {a, b -> a[0] == b[0]? a[1]<=>b[1]:a[0] <=> b[0]}.each {
+       def projectName = it[0]
+       def taskName = it[1]
+       def result = it[2]
+       def time = it[3]
+       def report = it[4]
+       def summaryCol = getSummaryLine(styler, projectName, taskName, result.resultType, result.testCount, result.successfulTestCount, result.failedTestCount, result.skippedTestCount, time, true)
+       def summaryPlain = getSummaryLine(styler, projectName, taskName, result.resultType, result.testCount, result.successfulTestCount, result.failedTestCount, result.skippedTestCount, time, false)
+       def reportLine = "Report file: ${report}"
+       def ls = summaryPlain.length()
+       def lr = reportLine.length()
+       def m = [ls, lr].max()
+       if (m > maxLength)
+         maxLength = m
+       def info = [ls, summaryCol, reportLine]
+       summaryLines.add(info)
+       failedTests |= result.resultType == TestResult.ResultType.FAILURE
+       totalcount += result.testCount
+       totalsuccess += result.successfulTestCount
+       totalfail += result.failedTestCount
+       totalskip += result.skippedTestCount
+       totaltime += time
+     }
+     def totalSummaryCol = getSummaryLine(styler, "OVERALL", "", failedTests?TestResult.ResultType.FAILURE:TestResult.ResultType.SUCCESS, totalcount, totalsuccess, totalfail, totalskip, totaltime, true)
+     def totalSummaryPlain = getSummaryLine(styler, "OVERALL", "", failedTests?TestResult.ResultType.FAILURE:TestResult.ResultType.SUCCESS, totalcount, totalsuccess, totalfail, totalskip, totaltime, false)
+     def tls = totalSummaryPlain.length()
+     if (tls > maxLength)
+       maxLength = tls
+     def info = [tls, totalSummaryCol, null]
+     summaryLines.add(info)
+     def allSummaries = []
+     for(sInfo : summaryLines) {
+       def ls = sInfo[0]
+       def summary = sInfo[1]
+       def report = sInfo[2]
+       StringBuilder sb = new StringBuilder()
+       sb.append("│" + summary + " " * (maxLength - ls) + "│")
+       if (report != null) {
+         sb.append("\n│" + report + " " * (maxLength - report.length()) + "│")
+       }
+       allSummaries += sb.toString()
+     }
+     println "┌${"${"─" * maxLength}"}┐"
+     println allSummaries.join("\n├${"${"─" * maxLength}"}┤\n")
+     println "└${"${"─" * maxLength}"}┘"
+ }
+ /* END of test tasks results summary */
  
 +/*
  task compileLinkCheck(type: JavaCompile) {
    options.fork = true
    classpath = files("${jalviewDir}/${utils_dir}")
@@@ -1813,8 -2066,8 +2085,8 @@@ jar 
      "Implementation-Version": JALVIEW_VERSION
    }
  
-   def destinationDirectory = "${jalviewDir}/${package_dir}"
-   destinationDirectory = file(destinationDirectory)
+   def outputDir = "${jalviewDir}/${package_dir}"
 -  destinationDirectory = file(outputDir)
++  outputDir = file(outputDir)
    archiveFileName = rootProject.name+".jar"
    duplicatesStrategy "EXCLUDE"