ok, sure. It is a little bit complicated, but here it is (or at least one of them). Included below is a build file of one of the projects, which is just a part of the overall build (all held together by a settings.gradle file which includes all the projects which should build together)
apply plugin: ‘java’
if (getProject().properties[‘codeCoverageProvider’]==null)
getProject().setProperty(‘codeCoverageProvider’, ‘/mnt/data/bin/cobertura-1.9.4.1’)
def buildTime = new java.util.Date()
configurations{
zkm
instrumentation }
dependencies {
instrumentation files("${project.buildDir}/cobertura-instrumentation")
testRuntime files("${codeCoverageProvider}/cobertura.jar")
testCompile files("${buildLibs}/junit.jar")
testCompile files("${buildHome}/mySignedJar.jar")
testCompile project(’:general/ModulesTestCaseBase’)
testCompile project(’:data_export/CustomMod2/CUShared’)
zkm files(zelix_lib)
compile files("${buildHome}/mySignedJar.jar") }
sourceSets {
main {
java {
srcDir ‘src’
}
resources {
srcDir ‘src’
}
}
test {
java {
srcDir ‘test’
}
resources {
srcDir ‘test’
}
runtimeClasspath = configurations.instrumentation + runtimeClasspath
} }
test{
workingDir = new File("${junitWorkingDir}")
ignoreFailures = true
systemProperties[‘net.sourceforge.cobertura.datafile’] = “${project.buildDir}/cobertura.ser” }
task obfuscate(dependsOn: classes) << {
javaexec {
main = ‘ZKM’
classpath = configurations.zkm + sourceSets.main.runtimeClasspath
args “$projectDir/script.txt”
jvmArgs “-DSaveAllDir=$buildDir/obfuscated-classes-extra”
} }
task jar(dependsOn: obfuscate, type: Jar, overwrite: true){ // we provide our own main jar task
manifest.from(“src/META-INF/MANIFEST.MF”)
// because our main jar should be obfuscated
manifest.attributes ‘Build-Time’: buildTime.toString()
from project.sourceSets.main.resources
from “$buildDir/obfuscated-classes-extra” }
task unobfuscatedJar(dependsOn: classes, type: Jar) { // we also provide an extra jar task, to provide our unobfuscated jar
baseName = “${project.name}-unobfuscated”
manifest.from(“src/META-INF/MANIFEST.MF”)
manifest.attributes ‘Build-Time’: buildTime.toString()
from “$buildDir/classes/main” }
test.doFirst { // coverage
println “Setting up cobertura code coverage instrumentation”
ant.taskdef(resource:‘tasks.properties’) {
classpath {
pathelement(location:"${codeCoverageProvider}/cobertura.jar")
fileset(dir:"${codeCoverageProvider}/lib", includes:’*.jar’)
}
}
println “instrumentation to: ${project.buildDir}/cobertura-instrumentation”
ant.‘cobertura-instrument’(toDir: “${project.buildDir}/cobertura-instrumentation”, datafile: “${project.buildDir}/cobertura.ser”){
fileset(dir: “${sourceSets.main.classesDir}”){
include(name: “**/*.class”)
}
} }
test.doLast{
println “Writing cobertura report”
ant.‘cobertura-report’(destdir: “${project.buildDir}/cobertura-report”, datafile: “${project.buildDir}/cobertura.ser”){
sourceSets.main.java.srcDirs.each { dir ->
if (dir.isDirectory()){
fileset(dir: “${dir}”){
include(name: “**/*.java”)
}
}
}
} }