X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=build.gradle;h=b659d8d2212526df69e8df41d175b8f86b3cf07c;hb=5ca5b92a5ea0cebe4f04d590ca7bbbc723c4dbc1;hp=ec8267ad048050d47d98c4ebbc7cadceeef30779;hpb=c6153fe9672b467fe579dfc4e8b7a827586d2d36;p=jalview.git diff --git a/build.gradle b/build.gradle index ec8267a..b659d8d 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 { @@ -42,11 +44,40 @@ sourceSets { compileClasspath = files(sourceSets.main.java.outputDir) compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"]) - //compileClasspath += fileTree(dir: "$jalviewDir/$j11libDir", 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"]) + + runtimeClasspath = compileClasspath + } + + clover { + java { + srcDirs = [ cloverInstrDir ] + outputDir = file("${buildDir}/clover-classes") + } + + 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" @@ -57,21 +88,71 @@ sourceSets { srcDirs = sourceSets.main.resources.srcDirs } - compileClasspath = sourceSets.main.compileClasspath - compileClasspath += 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")) { + 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' +} + +configurations { + cloverRuntime + cloverRuntime.extendsFrom cloverCompile +} + +task cloverInstr() { + // 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 { + 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) + } +} - runtimeClasspath = compileClasspath - } +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 { @@ -87,16 +168,59 @@ compileJava { '--add-modules', j11modules ] } + print ("Setting target compatibility to "+targetCompatibility+"\n") } } +compileTestJava { + dependsOn 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 } cleanTest { delete sourceSets.test.java.outputDir + delete cloverInstrDir } def getDate(format) { @@ -176,6 +300,7 @@ task syncLib(type: Sync) { task syncResources(type: Sync) { from "$jalviewDir/$resourceDir" include "**/*.*" + exclude "install4j" into "$jalviewDir/$classesDir" preserve { include "**" @@ -188,15 +313,35 @@ task prepare { dependsOn copyHelp } + //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir test { dependsOn prepare - dependsOn compileJava - useTestNG { + + + useTestNG() { includeGroups testngGroups + preserveOrder true + useDefaultListeners=true } + workingDir = jalviewDir //systemProperties 'clover.jar' System.properties.clover.jar + if (JAVA_VERSION.equals("1.8")) { + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + } else if (JAVA_VERSION.equals("11")) { + sourceCompatibility = 11 + targetCompatibility = 11 + + jvmArgs += [ + '--module-path', + sourceSets.modules.compileClasspath.asPath, + '--add-modules', + j11modules + ] + } + print ("Setting target compatibility to "+targetCompatibility+"\n") } task buildIndices(type: JavaExec) { @@ -340,24 +485,32 @@ task getdownWebsite() { } props.each{ prop, val -> if (prop.startsWith("getdown_txt_") && val != null) { - // file values rationalised - if (val.indexOf('/') > -1) { - def r = null - if (val.indexOf('/') == 0) { - // absolute path - r = file(val) - } else if (val.indexOf('/') > 0) { - // relative path (relative to jalviewDir) - r = file( jalviewDir + '/' + val ) + if (prop.startsWith("getdown_txt_multi_")) { + def key = prop.substring(18) + val.split(",").each{ v -> + def line = key + " = " + v + "\n" + getdownTextString += line } - if (r.exists()) { - val = getdown_resource_dir + '/' + r.getName() - getdownWebsiteResourceFilenames += val - getdownResourceFilenames += r.getPath() + } else { + // file values rationalised + if (val.indexOf('/') > -1) { + def r = null + if (val.indexOf('/') == 0) { + // absolute path + r = file(val) + } else if (val.indexOf('/') > 0) { + // relative path (relative to jalviewDir) + r = file( jalviewDir + '/' + val ) + } + if (r.exists()) { + val = getdown_resource_dir + '/' + r.getName() + getdownWebsiteResourceFilenames += val + getdownResourceFilenames += r.getPath() + } } + def line = prop.substring(12) + " = " + val + "\n" + getdownTextString += line } - def line = prop.substring(12) + " = " + val + "\n" - getdownTextString += line } } @@ -479,3 +632,4 @@ task installers(type: com.install4j.gradle.Install4jTask) { inputs.dir(project.ext.getdownWebsiteDir) outputs.dir("$jalviewDir/$install4jBuildDir") } +