X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=build.gradle;h=c34128e84bd183f50a02abcfa3e0f12829f18209;hb=refs%2Fheads%2Fjims%2FJAL-3130_Java11_Gradle_publishing;hp=ed8a9ab0d4af1fe7628428285d9a00733fcae5c2;hpb=6dcb8028ff88bbad2b032435b8e49ae1caeca3b6;p=jalview.git diff --git a/build.gradle b/build.gradle index ed8a9ab..c34128e 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")) { + use_clover = true + classes = "$buildDir/$cloverClassesDir" +} else { + use_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,18 @@ 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 (use_clover) { + compileClasspath += sourceSets.clover.compileClasspath + } else { + compileClasspath += sourceSets.main.compileClasspath + compileClasspath += files(sourceSets.main.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")) { - print("ADDING J11LIBS TO CLASSPATH") + print("ADDING J11LIBS TO CLASSPATH\n") compileClasspath += fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]) } @@ -106,8 +117,10 @@ sourceSets { // clover bits dependencies { - cloverCompile 'org.openclover:clover:4.3.1' - testCompile 'org.openclover:clover:4.3.1' + if (use_clover) { + cloverCompile 'org.openclover:clover:4.3.1' + testCompile 'org.openclover:clover:4.3.1' + } } configurations { @@ -123,7 +136,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 +146,6 @@ task cloverInstr() { } } -test.dependsOn cloverInstr - task cloverReport { inputs.dir "${buildDir}/clover" @@ -147,6 +158,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) } } @@ -174,7 +190,13 @@ compileJava { } compileTestJava { - dependsOn compileCloverJava + + if (use_clover) { + dependsOn compileCloverJava + classpath += configurations.cloverRuntime + } else { + classpath += sourceSets.main.runtimeClasspath + } doFirst { if (JAVA_VERSION.equals("1.8")) { sourceCompatibility = 1.8 @@ -190,7 +212,6 @@ compileTestJava { } print ("Setting target compatibility to "+targetCompatibility+"\n") } - classpath += configurations.cloverRuntime } @@ -252,7 +273,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") @@ -260,29 +281,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"]) @@ -292,7 +313,7 @@ task copyHelp(type: Copy) { } task syncLib(type: Sync) { - def syncDir = "$jalviewDir/$classesDir/$libDir" + def syncDir = "$classes/$libDir" from fileTree("$jalviewDir/$libDir") into syncDir } @@ -301,7 +322,7 @@ task syncResources(type: Sync) { from "$jalviewDir/$resourceDir" include "**/*.*" exclude "install4j" - into "$jalviewDir/$classesDir" + into "$classes" preserve { include "**" } @@ -317,12 +338,16 @@ task prepare { //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir test { dependsOn prepare + dependsOn compileJava + if (use_clover) { + dependsOn cloverInstr + } + print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n") - - useTestNG() - options { + useTestNG() { includeGroups testngGroups preserveOrder true + useDefaultListeners=true } workingDir = jalviewDir @@ -348,13 +373,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") @@ -377,8 +402,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") @@ -412,12 +439,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" }