From: Jim Procter Date: Fri, 12 Apr 2019 15:06:54 +0000 (+0100) Subject: JAL-3130 gradle test now runs open clover 4.3.1 and new cloverReport task X-Git-Tag: Release_2_11_0~17^2~7^2~42 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f2b2d87b1b8235ff9f8da33238e8e4d1a64efb93;p=jalview.git JAL-3130 gradle test now runs open clover 4.3.1 and new cloverReport task --- diff --git a/build.gradle b/build.gradle index d4140bd..c6f86d6 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ import org.gradle.internal.os.OperatingSystem buildscript { dependencies { - //classpath files("$gradlePluginsDir/gradle-macappbundle-2.3.0-patched-2.3.0.jar") + classpath 'org.openclover:clover:4.3.1' } } @@ -18,12 +18,14 @@ plugins { repositories { jcenter() mavenCentral() + mavenLocal() flatDir { dirs gradlePluginsDir } } mainClassName = launcherClass +def cloverInstrDir = file("$buildDir/sources-instr") sourceSets { @@ -50,9 +52,35 @@ sourceSets { runtimeClasspath = compileClasspath } + modules { + compileClasspath = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]) + + runtimeClasspath = compileClasspath + } + + clover { + java { + srcDirs = [ cloverInstrDir ] + outputDir = file("$jalviewDir/$testOutputDir") + } + + resources { + srcDirs = sourceSets.main.resources.srcDirs + } + compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir ) + compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"]) + compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"]) + if (JAVA_VERSION.equals("1.8")) { + print("ADDING J11LIBS TO CLASSPATH") + compileClasspath += fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]) + } + + runtimeClasspath = compileClasspath + } + test { java { - srcDirs "$jalviewDir/$testSourceDir" + srcDirs = [ cloverInstrDir ] outputDir = file("$jalviewDir/$testOutputDir") } @@ -60,21 +88,66 @@ sourceSets { srcDirs = sourceSets.main.resources.srcDirs } - compileClasspath = sourceSets.main.compileClasspath - compileClasspath += files( sourceSets.test.java.outputDir ) + + compileClasspath += configurations.cloverRuntime + files( sourceSets.test.java.outputDir ) compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"]) + compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"]) + if (JAVA_VERSION.equals("1.8")) { + print("ADDING J11LIBS TO CLASSPATH") + compileClasspath += fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]) + } runtimeClasspath = compileClasspath } +} - modules { - compileClasspath = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]) +// clover bits +dependencies { + cloverCompile 'org.openclover:clover:4.3.1' + testCompile 'org.openclover:clover:4.3.1' +} - runtimeClasspath = compileClasspath - } +configurations { + cloverRuntime + cloverRuntime.extendsFrom cloverCompile +} + +task cloverInstr() { + inputs.files files (sourceSets.main.allJava, fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"])) + outputs.dir cloverInstrDir + doFirst { + delete cloverInstrDir + def argsList = ["--initstring", "${buildDir}/clover/clover.db", + "-d", "${buildDir}/sources-instr"] + argsList.addAll(inputs.files.files.collect({ file -> + file.absolutePath + })) + String[] args = argsList.toArray() + println("About to instrument "+args.length +" files") + com.atlassian.clover.CloverInstr.mainImpl(args) + } } +test.dependsOn cloverInstr + +task cloverReport { + inputs.dir "${buildDir}/clover" + outputs.dir "${reportsDir}/clover" + onlyIf { + file("${buildDir}/clover/clover.db").exists() + } + doFirst { + def argsList = ["--initstring", "${buildDir}/clover/clover.db", + "-o", "${reportsDir}/clover"] + String[] args = argsList.toArray() + com.atlassian.clover.reporters.html.HtmlReporter.runReport(args) + } +} + +// end clover bits + + compileJava { doFirst { @@ -112,8 +185,29 @@ compileTestJava { } 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 @@ -121,6 +215,7 @@ clean { cleanTest { delete sourceSets.test.java.outputDir + delete cloverInstrDir } def getDate(format) { @@ -213,12 +308,14 @@ task prepare { dependsOn copyHelp } + //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir test { dependsOn prepare - dependsOn compileJava - dependsOn compileTestJava - useTestNG { + + + useTestNG() + options { includeGroups testngGroups preserveOrder true } @@ -530,3 +627,4 @@ task installers(type: com.install4j.gradle.Install4jTask) { inputs.dir(project.ext.getdownWebsiteDir) outputs.dir("$jalviewDir/$install4jBuildDir") } +