From bfe07abf2c2716020ceeb37086c6d502121a2283 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 15 Apr 2019 17:17:09 +0100 Subject: [PATCH] JAL-3130 some clover fixes for helplinks. Use 'gradle test -Pclover=true' --- build.gradle | 83 ++++++++++++++++++++++++++++++++--------------------- gradle.properties | 6 ++-- 2 files changed, 54 insertions(+), 35 deletions(-) diff --git a/build.gradle b/build.gradle index 5f33b20..291d718 100644 --- a/build.gradle +++ b/build.gradle @@ -25,14 +25,22 @@ repositories { } mainClassName = launcherClass -def cloverInstrDir = file("$buildDir/sources-instr") +def cloverInstrDir = file("$buildDir/$cloverSourcesInstrDir") +def classes = "$jalviewDir/$classesDir" +if (clover.equals("true")) { + clover = true + classes = "$buildDir/$cloverClassesDir" +} else { + clover = false + classes = "$jalviewDir/$classesDir" +} sourceSets { main { java { srcDirs "$jalviewDir/$sourceDir" - outputDir = file("$jalviewDir/$classesDir") + outputDir = file("$classes") } resources { @@ -45,7 +53,7 @@ sourceSets { compileClasspath = files(sourceSets.main.java.outputDir) compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"]) if (JAVA_VERSION.equals("1.8")) { - print("ADDING J11LIBS TO CLASSPATH") + print("ADDING J11LIBS TO CLASSPATH\n") compileClasspath += fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]) } @@ -61,7 +69,7 @@ sourceSets { clover { java { srcDirs = [ cloverInstrDir ] - outputDir = file("${buildDir}/clover-classes") + outputDir = file("${buildDir}/${cloverClassesDir}") } resources { @@ -71,7 +79,7 @@ sourceSets { 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") + print("ADDING J11LIBS TO CLASSPATH\n") compileClasspath += fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]) } @@ -88,15 +96,17 @@ sourceSets { srcDirs = sourceSets.main.resources.srcDirs } - - compileClasspath = configurations.cloverRuntime - compileClasspath += files( sourceSets.test.java.outputDir ) - compileClasspath += files( sourceSets.clover.java.outputDir ) + compileClasspath = files( sourceSets.test.java.outputDir ) + if (clover) { + compileClasspath += sourceSets.clover.compileClasspath + } else { + compileClasspath += sourceSets.main.compileClasspath + } 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")) { - print("ADDING J11LIBS TO CLASSPATH") + print("ADDING J11LIBS TO CLASSPATH\n") compileClasspath += fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]) } @@ -106,8 +116,10 @@ sourceSets { // clover bits dependencies { - cloverCompile 'org.openclover:clover:4.3.1' - testCompile 'org.openclover:clover:4.3.1' + if (clover) { + cloverCompile 'org.openclover:clover:4.3.1' + testCompile 'org.openclover:clover:4.3.1' + } } configurations { @@ -123,7 +135,7 @@ task cloverInstr() { doFirst { delete cloverInstrDir def argsList = ["--initstring", "${buildDir}/clover/clover.db", - "-d", "${buildDir}/sources-instr"] + "-d", "${buildDir}/${cloverSourcesInstrDir}"] argsList.addAll(inputs.files.files.collect({ file -> file.absolutePath })) @@ -133,8 +145,6 @@ task cloverInstr() { } } -test.dependsOn cloverInstr - task cloverReport { inputs.dir "${buildDir}/clover" @@ -179,7 +189,10 @@ compileJava { } compileTestJava { - dependsOn compileCloverJava + if (clover) { + dependsOn compileCloverJava + classpath += configurations.cloverRuntime + } doFirst { if (JAVA_VERSION.equals("1.8")) { sourceCompatibility = 1.8 @@ -195,7 +208,6 @@ compileTestJava { } print ("Setting target compatibility to "+targetCompatibility+"\n") } - classpath += configurations.cloverRuntime } @@ -257,7 +269,7 @@ def getGitBranch() { task createBuildProperties(type: WriteProperties) { inputs.dir("$jalviewDir/$sourceDir") inputs.dir("$jalviewDir/$resourceDir") - outputFile "$jalviewDir/$classesDir/$buildPropertiesFile" + outputFile "$classes/$buildPropertiesFile" /* taking time/date specific comment out to allow better incremental builds */ //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss") comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd") @@ -265,29 +277,29 @@ task createBuildProperties(type: WriteProperties) { property "VERSION", JALVIEW_VERSION property "INSTALLATION", INSTALLATION+" git-commit:"+getGitHash()+" ["+getGitBranch()+"]" outputs.file(outputFile) - outputs.dir("$jalviewDir/$classesDir") + outputs.dir("$classes") } task syncDocs(type: Sync) { - def syncDir = "$jalviewDir/$classesDir/$docDir" + def syncDir = "$classes/$docDir" from fileTree("$jalviewDir/$docDir") into syncDir } -def helpFile = "$jalviewDir/$classesDir/$helpDir/help.jhm" +def helpFile = "$classes/$helpDir/help.jhm" task syncHelp(type: Sync) { inputs.files("$jalviewDir/$helpDir") outputs.files(helpFile) - def syncDir = "$jalviewDir/$classesDir/$helpDir" + def syncDir = "$classes/$helpDir" from fileTree("$jalviewDir/$helpDir") into syncDir } task copyHelp(type: Copy) { def inputDir = "$jalviewDir/$helpDir" - def outputDir = "$jalviewDir/$classesDir/$helpDir" + def outputDir = "$classes/$helpDir" from inputDir into outputDir filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': "USING_FILTER"]) @@ -297,7 +309,7 @@ task copyHelp(type: Copy) { } task syncLib(type: Sync) { - def syncDir = "$jalviewDir/$classesDir/$libDir" + def syncDir = "$classes/$libDir" from fileTree("$jalviewDir/$libDir") into syncDir } @@ -306,7 +318,7 @@ task syncResources(type: Sync) { from "$jalviewDir/$resourceDir" include "**/*.*" exclude "install4j" - into "$jalviewDir/$classesDir" + into "$classes" preserve { include "**" } @@ -322,7 +334,10 @@ task prepare { //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir test { dependsOn prepare - + if (clover) { + dependsOn cloverInstr + } + print("Running tests " + (clover?"WITH":"WITHOUT") + " clover [clover="+clover+"]\n") useTestNG() { includeGroups testngGroups @@ -353,13 +368,13 @@ task buildIndices(type: JavaExec) { dependsOn copyHelp classpath = sourceSets.main.compileClasspath main = "com.sun.java.help.search.Indexer" - workingDir = "$jalviewDir/$classesDir/$helpDir" + workingDir = "$classes/$helpDir" def argDir = "html" args = [ argDir ] inputs.dir("$workingDir/$argDir") - outputs.dir("$jalviewDir/$classesDir/doc") - outputs.dir("$jalviewDir/$classesDir/help") + outputs.dir("$classes/doc") + outputs.dir("$classes/help") outputs.file("$workingDir/JavaHelpSearch/DOCS") outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB") outputs.file("$workingDir/JavaHelpSearch/OFFSETS") @@ -382,8 +397,10 @@ task linkCheck(type: JavaExec) { dependsOn prepare, compileLinkCheck classpath = files("$jalviewDir/$utilsDir") main = "HelpLinksChecker" - workingDir = "$jalviewDir" - args = [ "$classesDir/$helpDir", "-nointernet" ] + workingDir = jalviewDir + def help = "$classes/$helpDir" + args = [ "$classes/$helpDir", "-nointernet" ] + //args = [ "$classesDir/$helpDir", "-nointernet" ] doFirst { standardOutput new FileOutputStream("$jalviewDir/$utilsDir/HelpLinksChecker.out") @@ -417,12 +434,12 @@ jar { exclude "**/*.jar" exclude "**/*.jar.*" - inputs.dir("$jalviewDir/$classesDir") + inputs.dir("$classes") outputs.file("$jalviewDir/$packageDir/$archiveName") } task copyJars(type: Copy) { - from fileTree("$jalviewDir/$classesDir").include("**/*.jar").include("*.jar").files + from fileTree("$classes").include("**/*.jar").include("*.jar").files into "$jalviewDir/$packageDir" } diff --git a/gradle.properties b/gradle.properties index cb335d6..6533899 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ #org.gradle.java.home = /Users/bsoares/Java/installs/OpenJDK8U-jdk_x64_mac_hotspot_8u192b12/jdk8u192-b12/Contents/Home jalviewDir = . -JAVA_VERSION = 11 +JAVA_VERSION = 1.8 JALVIEW_VERSION = DEVELOPMENT INSTALLATION = Source jalview_keystore = keys/.keystore @@ -26,7 +26,9 @@ docDir = doc sourceDir = src schemaDir = schemas classesDir = classes -clover.classesDir = cloverclasses +clover = false +cloverClassesDir = clover-classes +cloverSourcesInstrDir = sources-instr packageDir = dist outputJar = jalview.jar -- 1.7.10.2