-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cd80fa
commit c24558d
Showing
5 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,7 @@ | |
.externalNativeBuild | ||
app/src/main/aidl/ | ||
app/*.apk | ||
/.idea/ | ||
/.idea/ | ||
|
||
# ignore jacoco coverage reports | ||
/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
apply plugin: 'jacoco' | ||
|
||
jacoco { | ||
toolVersion = "0.8.4" | ||
} | ||
|
||
tasks.withType(Test) { | ||
jacoco.includeNoLocationClasses = true | ||
} | ||
|
||
afterEvaluate { | ||
|
||
task jacocoTestReport(type: JacocoReport) { | ||
outputs.cacheIf { true } | ||
|
||
Task runTestsTask | ||
|
||
group "Reporting" | ||
description "Generate Jacoco coverage reports." | ||
|
||
print "configuring jacoco for project: ${project.name}" | ||
|
||
if (project.tasks.findByName('testDevelopDebugUnitTest')) { | ||
runTestsTask = project.tasks.findByName('testDevelopDebugUnitTest') | ||
} else { | ||
runTestsTask = project.tasks.findByName('testDebugUnitTest') | ||
} | ||
|
||
|
||
dependsOn runTestsTask | ||
|
||
def outputFileName = "coverage/coverage-${project.name}.xml" | ||
def outputFileNameHtml = "coverage/coverage-${project.name}.html" | ||
|
||
def file = new File("coverage/") | ||
if (!file.exists()) file.mkdirs() | ||
|
||
reports { | ||
xml.enabled = true | ||
html.enabled = true | ||
html.setDestination(new File(outputFileNameHtml)) | ||
xml.setDestination(new File(outputFileName)) | ||
} | ||
|
||
outputs.upToDateWhen { false } | ||
|
||
def javaClasses = [] | ||
def kotlinClasses = [] | ||
def sourceDirs = [] | ||
def execution = [] | ||
|
||
def fileFilter = ['**/R.class', | ||
'**/R$*.class', | ||
'**/BuildConfig.*', | ||
'**/Manifest*.*', | ||
'**/*Test.*', | ||
'**/*Activity.*', | ||
'**/*Fragment.*', | ||
'**/*Adapter.*', | ||
'**/*Holder.*', | ||
'**/*App.*', | ||
'**/*Application.*', | ||
'**/*Dialog.*', | ||
'**/*Ext.*', | ||
'**/*ViewPager.*', | ||
'**/*Module.*', | ||
'**/*Dependencies.*', | ||
'**/*Router.*', | ||
'**/*Component.*', | ||
'**/*ViewModelFactory.*', | ||
'**/*Api.*', | ||
'**/*Dao.*', | ||
'android/**/*.*', | ||
'**/com/google/protobuf/**/*.*', | ||
'**/com/google/api/*.*', | ||
'**/data/db/dao/*.*', | ||
'**/android/databinding/layouts/*.*', | ||
'**/androidx/databinding/library/baseAdapters/*.*', | ||
'**/*Activity.*', | ||
'**/*Fragment.*', | ||
'**/di/**', | ||
'**/view/**', | ||
] | ||
|
||
javaClasses << fileTree(dir: "$buildDir/intermediates/javac/debug", excludes: fileFilter) | ||
|
||
kotlinClasses << fileTree(dir: "$buildDir/tmp/kotlin-classes/debug", excludes: fileFilter) | ||
|
||
sourceDirs << fileTree(dir: "$projectDir/src/main/java", excludes: fileFilter) | ||
|
||
execution << fileTree(dir: buildDir, | ||
includes: ["jacoco/${runTestsTask.name}.exec", | ||
'outputs/code_coverage/debugAndroidTest/connected/**/*.ec']) | ||
|
||
executionData.setFrom(files(execution)) | ||
sourceDirectories.setFrom(files([sourceDirs])) | ||
classDirectories.setFrom(files([javaClasses, kotlinClasses])) | ||
|
||
doFirst { | ||
print "generating jacoco report for project: ${project.name} \n" | ||
print "sourceDirs = " + sourceDirs + '\n' | ||
print "execution = " + execution + '\n' | ||
print "classDirectoriesJava = " + javaClasses + '\n' | ||
print "classDirectoriesKT = " + kotlinClasses + '\n' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apply from: '../jacoco.gradle' | ||
|
||
afterEvaluate { | ||
task runModuleTests { | ||
Task runTestsTask | ||
if (project.tasks.findByName('testDevelopDebugUnitTest')) { | ||
runTestsTask = project.tasks.findByName('testDevelopDebugUnitTest') | ||
} else { | ||
runTestsTask = project.tasks.findByName('testDebugUnitTest') | ||
} | ||
|
||
dependsOn runTestsTask | ||
|
||
group "Verification" | ||
} | ||
} |