mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Add jacocoRootReport task to build.gradle
with the correct parameters to collect the jacocoReports from all subprojects and put the jacocoTestReport.xml in the right place, so that the coveralls plugin is able to find it.
This commit is contained in:
parent
03206fcbf6
commit
4d9bd6f216
2 changed files with 55 additions and 20 deletions
|
@ -6,4 +6,4 @@ install: gradle assemble
|
||||||
script: gradle check
|
script: gradle check
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- gradle jacocoTestReport coveralls
|
- gradle jacocoRootReport coveralls
|
||||||
|
|
73
build.gradle
73
build.gradle
|
@ -18,6 +18,7 @@ apply from: 'version.gradle'
|
||||||
allprojects {
|
allprojects {
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
|
apply plugin: 'jacoco'
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
gitCommit = getGitCommit()
|
gitCommit = getGitCommit()
|
||||||
|
@ -35,6 +36,23 @@ allprojects {
|
||||||
// build, causing unnecessary rebuilds.
|
// build, causing unnecessary rebuilds.
|
||||||
builtDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
|
builtDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
|
||||||
oneLineDesc = 'An Open Source XMPP (Jabber) client library'
|
oneLineDesc = 'An Open Source XMPP (Jabber) client library'
|
||||||
|
// A dirty hack used for Gradle's jacoco plugin, since is not
|
||||||
|
// hable to handle the case when a (sub)project has no unit
|
||||||
|
// tests. :-(
|
||||||
|
projectsWithoutUnitTests = [
|
||||||
|
':smack-android',
|
||||||
|
':smack-android-extensions',
|
||||||
|
':smack-bosh',
|
||||||
|
':smack-compression-jzlib',
|
||||||
|
':smack-debug',
|
||||||
|
':smack-debug-slf4j',
|
||||||
|
':smack-java7',
|
||||||
|
':smack-jingle-old',
|
||||||
|
':smack-resolver-dnsjava',
|
||||||
|
':smack-resolver-javax',
|
||||||
|
':smack-resolver-minidns',
|
||||||
|
].collect{ project(it) }
|
||||||
|
projectsWithUnitTests = subprojects - projectsWithoutUnitTests
|
||||||
androidProjects = [
|
androidProjects = [
|
||||||
':smack-tcp',
|
':smack-tcp',
|
||||||
':smack-bosh',
|
':smack-bosh',
|
||||||
|
@ -79,6 +97,8 @@ allprojects {
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
// Add OSS Sonatype Snapshot repository
|
// Add OSS Sonatype Snapshot repository
|
||||||
maven {
|
maven {
|
||||||
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
||||||
|
@ -97,6 +117,19 @@ allprojects {
|
||||||
options.addStringOption('Xdoclint:none', '-quiet')
|
options.addStringOption('Xdoclint:none', '-quiet')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jacoco {
|
||||||
|
toolVersion = "0.7.4.201502262128"
|
||||||
|
}
|
||||||
|
|
||||||
|
jacocoTestReport {
|
||||||
|
dependsOn test
|
||||||
|
sourceDirectories = project.files(sourceSets.main.allSource.srcDirs)
|
||||||
|
classDirectories = project.files(sourceSets.main.output)
|
||||||
|
reports {
|
||||||
|
xml.enabled true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gradle.taskGraph.whenReady { taskGraph ->
|
gradle.taskGraph.whenReady { taskGraph ->
|
||||||
|
@ -182,17 +215,11 @@ subprojects {
|
||||||
apply plugin: 'osgi'
|
apply plugin: 'osgi'
|
||||||
apply plugin: 'signing'
|
apply plugin: 'signing'
|
||||||
apply plugin: 'checkstyle'
|
apply plugin: 'checkstyle'
|
||||||
apply plugin: 'jacoco'
|
|
||||||
apply plugin: 'org.kordamp.gradle.clirr'
|
apply plugin: 'org.kordamp.gradle.clirr'
|
||||||
apply plugin: "com.github.kt3k.coveralls"
|
|
||||||
|
|
||||||
checkstyle {
|
checkstyle {
|
||||||
configFile = new File(rootConfigDir, 'checkstyle.xml')
|
configFile = new File(rootConfigDir, 'checkstyle.xml')
|
||||||
}
|
}
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||||
classifier = 'sources'
|
classifier = 'sources'
|
||||||
from sourceSets.main.allSource
|
from sourceSets.main.allSource
|
||||||
|
@ -289,19 +316,6 @@ subprojects {
|
||||||
baseline = [group, name, clirrBaseline].join(':')
|
baseline = [group, name, clirrBaseline].join(':')
|
||||||
failOnErrors clirrFailOnErrors
|
failOnErrors clirrFailOnErrors
|
||||||
}
|
}
|
||||||
|
|
||||||
jacoco {
|
|
||||||
toolVersion = "0.7.1.201405082137"
|
|
||||||
}
|
|
||||||
|
|
||||||
jacocoTestReport {
|
|
||||||
dependsOn test
|
|
||||||
sourceDirectories = project.files(sourceSets.main.allSource.srcDirs)
|
|
||||||
classDirectories = project.files(sourceSets.main.output)
|
|
||||||
reports {
|
|
||||||
xml.enabled true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects*.jar {
|
subprojects*.jar {
|
||||||
|
@ -310,6 +324,27 @@ subprojects*.jar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply plugin: "com.github.kt3k.coveralls"
|
||||||
|
coveralls {
|
||||||
|
sourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs).files.absolutePath
|
||||||
|
}
|
||||||
|
|
||||||
|
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
|
||||||
|
dependsOn = projectsWithUnitTests.jacocoTestReport
|
||||||
|
sourceDirectories = files(projectsWithUnitTests.sourceSets.main.allSource.srcDirs)
|
||||||
|
classDirectories = files(projectsWithUnitTests.sourceSets.main.output)
|
||||||
|
executionData = files(projectsWithUnitTests.jacocoTestReport.executionData)
|
||||||
|
reports {
|
||||||
|
xml.enabled true
|
||||||
|
xml.destination ="${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
|
||||||
|
}
|
||||||
|
// We could remove the following setOnlyIf line, but then
|
||||||
|
// jacocoRootReport would silently be SKIPPED if something with
|
||||||
|
// the projectsWithUnitTests is wrong (e.g. a project is missing
|
||||||
|
// in there).
|
||||||
|
setOnlyIf { true }
|
||||||
|
}
|
||||||
|
|
||||||
// Important to specify this task after the subprojects block
|
// Important to specify this task after the subprojects block
|
||||||
task clirrRootReport(type: org.kordamp.gradle.clirr.ClirrReportTask) {
|
task clirrRootReport(type: org.kordamp.gradle.clirr.ClirrReportTask) {
|
||||||
dependsOn = subprojects.tasks.clirr
|
dependsOn = subprojects.tasks.clirr
|
||||||
|
|
Loading…
Reference in a new issue