JAL-3130 write clover.xml during cloverReport phase
[jalview.git] / build.gradle
index c6f86d6..5f33b20 100644 (file)
@@ -61,7 +61,7 @@ sourceSets {
   clover {
     java {
         srcDirs = [ cloverInstrDir ]
-        outputDir = file("$jalviewDir/$testOutputDir")
+        outputDir = file("${buildDir}/clover-classes")
     }
     
     resources {
@@ -80,7 +80,7 @@ sourceSets {
   
   test {
     java {
-      srcDirs = [ cloverInstrDir ]
+      srcDirs "$jalviewDir/$testSourceDir"
       outputDir = file("$jalviewDir/$testOutputDir")
     }
 
@@ -89,7 +89,10 @@ sourceSets {
     }
 
 
-    compileClasspath += configurations.cloverRuntime + files( sourceSets.test.java.outputDir )
+    compileClasspath = configurations.cloverRuntime 
+    compileClasspath += files( sourceSets.test.java.outputDir ) 
+    compileClasspath += files( sourceSets.clover.java.outputDir )
+    compileClasspath += files( sourceSets.main.resources.srcDirs)
     compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
     compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
     if (JAVA_VERSION.equals("1.8")) {
@@ -113,7 +116,8 @@ configurations {
 }
  
 task cloverInstr() {
-    inputs.files files (sourceSets.main.allJava, fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
+  // only instrument source, we build test classes as normal
+    inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
     outputs.dir cloverInstrDir
 
     doFirst {
@@ -130,6 +134,7 @@ task cloverInstr() {
 }
 
 test.dependsOn cloverInstr
+
  
 task cloverReport {
     inputs.dir "${buildDir}/clover"
@@ -142,6 +147,11 @@ task cloverReport {
                         "-o", "${reportsDir}/clover"]
         String[] args = argsList.toArray()
         com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
+        
+        // and generate ${reportsDir}/clover/clover.xml
+        args = ["--initstring", "${buildDir}/clover/clover.db",
+                        "-o", "${reportsDir}/clover/clover.xml"].toArray()
+        com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
     }
 }
 
@@ -169,7 +179,7 @@ compileJava {
 }
 
 compileTestJava {
-
+  dependsOn compileCloverJava
   doFirst {
     if (JAVA_VERSION.equals("1.8")) {
       sourceCompatibility = 1.8
@@ -189,25 +199,25 @@ compileTestJava {
 }
 
 
-//compileCloverJava {
-//
-//  doFirst {
-//    if (JAVA_VERSION.equals("1.8")) {
-//      sourceCompatibility = 1.8
-//      targetCompatibility = 1.8
-//    } else if (JAVA_VERSION.equals("11")) {
-//      sourceCompatibility = 11
-//      targetCompatibility = 11
-//
-//      options.compilerArgs += [
-//        '--module-path', sourceSets.modules.compileClasspath.asPath,
-//        '--add-modules', j11modules
-//      ]
-//    }
-//    print ("Setting target compatibility to "+targetCompatibility+"\n")
-//  }
-//  classpath += configurations.cloverRuntime
-//}
+compileCloverJava {
+
+  doFirst {
+    if (JAVA_VERSION.equals("1.8")) {
+      sourceCompatibility = 1.8
+      targetCompatibility = 1.8
+    } else if (JAVA_VERSION.equals("11")) {
+      sourceCompatibility = 11
+      targetCompatibility = 11
+
+      options.compilerArgs += [
+        '--module-path', sourceSets.modules.compileClasspath.asPath,
+        '--add-modules', j11modules
+      ]
+    }
+    print ("Setting target compatibility to "+targetCompatibility+"\n")
+  }
+  classpath += configurations.cloverRuntime
+}
 
 clean {
   delete sourceSets.main.java.outputDir
@@ -314,10 +324,10 @@ test {
   dependsOn prepare
   
   
-  useTestNG()
-  options {
+  useTestNG() {
     includeGroups testngGroups
     preserveOrder true
+    useDefaultListeners=true
   }
   
   workingDir = jalviewDir