From: Jim Procter Date: Fri, 12 Apr 2019 16:35:32 +0000 (+0100) Subject: JAL-3130 instrument main and compile separately to test classes so Clover doesn’t... X-Git-Tag: Release_2_11_0~17^2~7^2~41 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6dcb8028ff88bbad2b032435b8e49ae1caeca3b6;p=jalview.git JAL-3130 instrument main and compile separately to test classes so Clover doesn’t misclassify them --- diff --git a/build.gradle b/build.gradle index c6f86d6..ed8a9ab 100644 --- a/build.gradle +++ b/build.gradle @@ -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" @@ -169,7 +174,7 @@ compileJava { } compileTestJava { - + dependsOn compileCloverJava doFirst { if (JAVA_VERSION.equals("1.8")) { sourceCompatibility = 1.8 @@ -189,25 +194,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