Skip to content

Commit

Permalink
Coveralls (#21)
Browse files Browse the repository at this point in the history
* Fixed coveralls (include all modules). *4

* Fixed coveralls (include all modules). *5

* Fixed coveralls (include all modules). *6

* Fixed coveralls (include all modules). *7

* Fixed coveralls (include all modules). *8

* Fixed coveralls (include all modules). *9

* Fixed coveralls (include all modules). *10

* Fixed coveralls (include all modules). *10

* Fixed coveralls (include all modules). *11
  • Loading branch information
d4rken committed Mar 18, 2018
1 parent 23e9419 commit f99f2c0
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ before_install:

script: ./gradlew clean assemble test

after_success: ./gradlew jacocoMerge jacocoRootReport coveralls
after_success: ./gradlew jacocoRootReport coveralls
47 changes: 20 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ buildscript {
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
//noinspection GradleDependency
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.5.0-x'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
}
}

apply plugin: 'java'

apply plugin: "com.github.kt3k.coveralls"
apply plugin: 'jacoco'
apply plugin: 'java'

allprojects {
apply plugin: 'jacoco'
repositories {
google()
jcenter()
Expand All @@ -86,22 +87,19 @@ allprojects {

subprojects { subProject ->
def exclude = ['eu/darken/R*.class', '**/BuildConfig.class', '**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*']
apply plugin: 'jacoco'
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
reports {
xml.enabled = true
html.enabled = true
}

def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: exclude)
def mainSrc = "${project.projectDir}/src/main/java"

sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
sourceDirectories = files(["${project.projectDir}/src/main/java"])
classDirectories = files([fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: exclude)])
executionData = fileTree(dir: "$project.buildDir", includes: [
"jacoco/testDebugUnitTest.exec",
"outputs/code-coverage/connected/*coverage.ec"
"jacoco/testDebugUnitTest.exec"
])

rootProject.coveralls.sourceDirs.addAll(sourceDirectories.flatten())
}

afterEvaluate {
Expand All @@ -110,7 +108,6 @@ subprojects { subProject ->
if (isLibrary) {
subProject.apply plugin: "com.github.dcendents.android-maven"
subProject.apply plugin: "com.jfrog.bintray"
subProject.apply plugin: "jacoco"

task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
Expand All @@ -123,34 +120,30 @@ subprojects { subProject ->
}
}
}
def publishedProjects = subprojects.findAll { it.path != ':example' }

task jacocoMerge(type: JacocoMerge) {
publishedProjects.each { subproject ->
executionData subproject.tasks.withType(Test)
}
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}
def publishedProjects = subprojects.findAll { !it.path.contains('example') }
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'

task jacocoRootReport(type: JacocoReport) {
dependsOn(publishedProjects.jacocoTestReport)

additionalSourceDirs = files(publishedProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(publishedProjects.jacocoTestReport.sourceDirectories)
classDirectories = files(publishedProjects.jacocoTestReport.classDirectories)
executionData = files(publishedProjects.jacocoTestReport.executionData)

reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
getReports().getHtml().setDestination(file("$buildDir/reports/jacocoRootReport/html"))
getReports().getXml().setDestination(file("$buildDir/reports/jacocoRootReport/merged.xml"))
}

coveralls {
sourceDirs = publishedProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath "build/reports/jacocoRootReport/merged.xml"
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}

tasks.coveralls {
group = 'Coverage reports'
description = 'Uploads the aggregated coverage report to Coveralls'
dependsOn jacocoRootReport
}
4 changes: 0 additions & 4 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ android {
textOutput 'stdout'
disable 'TimberTagLength'
}
buildTypes {
release {}
debug {}
}
}
afterEvaluate {
javadoc.classpath += files(android.libraryVariants.collect { variant ->
Expand Down
1 change: 1 addition & 0 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ dependencies {
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

testImplementation deps.jUnit
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
}
12 changes: 12 additions & 0 deletions example/src/test/java/eu/darken/rxshellexample/DummyTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package eu.darken.rxshellexample;

import org.junit.Test;

import static org.junit.Assert.assertTrue;

public class DummyTest {
@Test
public void test() {
assertTrue(true);
}
}
4 changes: 0 additions & 4 deletions root/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ android {
textOutput 'stdout'
disable 'TimberTagLength'
}
buildTypes {
release {}
debug {}
}
}

dependencies {
Expand Down

0 comments on commit f99f2c0

Please sign in to comment.