From 84869c99e109a9ef10c8e6621233995a45ac90bf Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Tue, 17 Mar 2020 19:19:59 +0000 Subject: [PATCH] JAL-3541 rejigged clover tasks very mildly --- build.gradle | 70 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/build.gradle b/build.gradle index 8dd6187..33d5278 100644 --- a/build.gradle +++ b/build.gradle @@ -7,12 +7,18 @@ import groovy.transform.ExternalizeMethods import groovy.util.XmlParser import groovy.xml.XmlUtil + buildscript { + repositories { + mavenCentral() + mavenLocal() + } dependencies { classpath 'org.openclover:clover:4.4.1' } } + plugins { id 'java' id 'application' @@ -26,12 +32,6 @@ repositories { jcenter() mavenCentral() mavenLocal() - flatDir { - dirs gradlePluginsDir - } -} - -dependencies { } @@ -104,6 +104,7 @@ ext { // clover cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}") + cloverDb = string("${buildDir}/clover/clover.db") classesDir = string("${jalviewDir}/${classes_dir}") if (clover.equals("true")) { use_clover = true @@ -404,18 +405,19 @@ sourceSets { // clover bits dependencies { + cloverCompile 'org.openclover:clover:4.4.1' if (use_clover) { - cloverCompile 'org.openclover:clover:4.4.1' testCompile 'org.openclover:clover:4.4.1' } } - configurations { cloverRuntime cloverRuntime.extendsFrom cloverCompile } + +// eclipse project and settings files creation, also used by buildship eclipse { project { name = eclipse_project_name @@ -550,18 +552,24 @@ eclipse { } -task cloverInstr() { +task cloverInstr { // only instrument source, we build test classes as normal inputs.files files (sourceSets.main.allJava,sourceSets.test.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"])) outputs.dir cloverInstrDir doFirst { - delete cloverInstrDir - def argsList = ["--initstring", "${buildDir}/clover/clover.db", - "-d", "${buildDir}/${cloverSourcesInstrDir}"] - argsList.addAll(inputs.files.files.collect({ file -> - file.absolutePath - })) + //delete cloverInstrDir + def argsList = [ + "--initstring", + cloverDb, + "-d", + cloverInstrDir.getPath(), + ] + 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) @@ -569,23 +577,34 @@ task cloverInstr() { } +cloverClasses.dependsOn cloverInstr + + task cloverReport { group = "Verification" - description = "Creates the Clover report" - inputs.dir "${buildDir}/clover" - outputs.dir "${reportsDir}/clover" - onlyIf { - file("${buildDir}/clover/clover.db").exists() - } + description = "Creates the Clover report" + inputs.dir "${buildDir}/clover" + outputs.dir "${reportsDir}/clover" + onlyIf { + file(cloverDb).exists() + } doFirst { - def argsList = ["--initstring", "${buildDir}/clover/clover.db", - "-o", "${reportsDir}/clover"] + def argsList = [ + "--initstring", + cloverDb, + "-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() + args = [ + "--initstring", + cloverDb, + "-o", + "${reportsDir}/clover/clover.xml" + ].toArray() com.atlassian.clover.reporters.xml.XMLReporter.runReport(args) } } @@ -643,6 +662,7 @@ cleanTest { doFirst { delete sourceSets.test.java.outputDir delete cloverInstrDir + delete cloverDb } } -- 1.7.10.2