Created
November 4, 2019 10:16
-
-
Save cesarioputera/6c0b7c40de061a820b2dc09e10b8c3b3 to your computer and use it in GitHub Desktop.
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
ext.excludeFileFilter = [ | |
//excludedFiles | |
] | |
jacoco { | |
toolVersion = "0.8.2" | |
} | |
ext { | |
limits = [ | |
'instruction': 50 | |
] | |
} | |
def includeFileFilter = [ | |
//IncludedFile | |
] | |
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/flavorUnsigned/debug", includes: includeFileFilter, excludes: excludeFileFilter) | |
def kotlinDebugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/flavorUnsignedDebug", includes: includeFileFilter, excludes: excludeFileFilter) | |
def mainSrc = "${project.projectDir}/src/main/java" | |
task jacocoTestReport(type: JacocoReport, dependsOn: ['testFlavorUnsignedDebugUnitTest', 'assembleDebug']) { | |
reports { | |
xml.enabled = true | |
html.enabled = true | |
} | |
sourceDirectories = files([mainSrc]) | |
classDirectories = files([debugTree], [kotlinDebugTree]) | |
executionData = fileTree(dir: "$buildDir", includes: [ | |
"jacoco/testFlavorUnsignedDebugUnitTest.exec", | |
]) | |
} | |
check.dependsOn jacocoTestReport | |
android { | |
testOptions { | |
unitTests.all { | |
jacoco { | |
includeNoLocationClasses = true | |
} | |
} | |
unitTests.returnDefaultValues = true | |
} | |
} |
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
sonarqube { | |
properties { | |
// recommend to specify the flavor once and dynamically adapt paths to it | |
def flavor = "flavorUnsigned" // flavor we want to have tested. Should be static | |
def Flavor = "FlavorUnsigned" // flavor again, but starting with upper case | |
/* SonarQube needs to be informed about your libraries and the android.jar to understand that methods like | |
* onResume() is called by the Android framework. Without that information SonarQube will very likely create warnings | |
* that those methods are never used and they should be removed. Same applies for libraries where parent classes | |
* are required to understand how a class works and is used. */ | |
def libraries = project.android.sdkDirectory.getPath() + "/platforms/android-26/android.jar," + | |
"build/intermediates/classes-jar/**/classes.jar" | |
property "sonar.projectKey", "BlibliAndroidApp" // some shortcut name | |
property "sonar.projectName", "Blibli Android App" | |
property "sonar.projectVersion", app_version | |
property "sonar.sourceEncoding", "UTF-8" | |
property "sonar.sources", "src/main/java" | |
// Defines where the java files are | |
property "sonar.binaries", "build/intermediates/classes/${flavor},build/tmp/kotlin-classes/${flavor}Debug" | |
property "sonar.libraries", libraries | |
// Defines where the xml files are | |
property "sonar.java.binaries", "build/intermediates/classes/${flavor},build/tmp/kotlin-classes/${flavor}Debug" | |
property "sonar.java.libraries", libraries | |
// Analyze tests classes | |
if (project.plugins.hasPlugin('com.android.application')) { | |
property "sonar.tests", "src/test/java,src/androidTest/java" | |
} else { | |
property "sonar.tests", "src/test/java" | |
} | |
property "sonar.java.test.binaries", "build/intermediates/classes/${flavor},build/tmp/kotlin-classes/${flavor}Debug" | |
property "sonar.java.test.libraries", libraries | |
property "sonar.scm.provider", "git" | |
property "sonar.jacoco.reportPaths", "build/jacoco/test${Flavor}DebugUnitTest.exec" | |
property "sonar.java.coveragePlugin", "jacoco" | |
property "sonar.junit.reportPaths", "build/test-results/test${Flavor}DebugUnitTest" | |
property "sonar.coverage.exclusions", excludeFileFilter.join(',') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment