Created
November 4, 2019 10:19
-
-
Save cesarioputera/859456a3846776ca82dd1904180ce964 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
apply from: "../jacoco.gradle" | |
def debugTree = fileTree(dir: "${buildDir}/intermediates/packaged-classes/flavorUnsigned", 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 | |
} | |
getSourceDirectories().setFrom(files([mainSrc])) | |
getClassDirectories().setFrom(files([debugTree], [kotlinDebugTree])) | |
getExecutionData().setFrom(fileTree(dir: "$buildDir", includes: [ | |
"jacoco/testFlavorUnsignedDebugUnitTest.exec", | |
])) | |
} | |
check.dependsOn jacocoTestReport |
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
apply plugin: "jacoco" | |
ext.excludeFileFilter = [ | |
//ExcludeFiles | |
] | |
jacoco { | |
toolVersion = "0.8.2" | |
} | |
ext { | |
limits = [ | |
'instruction': 50 | |
] | |
} | |
ext.includeFileFilter = [ | |
//IncludedFiles | |
] | |
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
apply from: '../sonarqube.gradle' | |
sonarqube { | |
//read the flavor from properties. | |
def flavorName = "flavorUnsigned" | |
def variant = "debug" | |
androidVariant flavorName + variant.capitalize() | |
properties { | |
def libraries = project.android.sdkDirectory.getPath() + "/platforms/android-28/android.jar" + ",build/intermediates/packaged-classes/**/classes.jar" | |
property "sonar.projectVersion", app_version | |
property 'sonar.binaries', "build/intermediates/packaged-classes/$flavorName,build/tmp/kotlin-classes/$androidVariant" | |
property "sonar.libraries", libraries | |
property 'sonar.java.binaries', "build/intermediates/packaged-classes/$flavorName,build/tmp/kotlin-classes/$androidVariant" | |
property "sonar.java.libraries", libraries | |
property 'sonar.java.test.binaries', "build/intermediates/packaged-classes/$flavorName,build/tmp/kotlin-classes/$androidVariant" | |
property "sonar.java.test.libraries", libraries | |
property 'sonar.junit.reportsPaths', "build/test-results/test${androidVariant.capitalize()}UnitTest" | |
property 'sonar.jacoco.reportPaths', "build/jacoco/test${androidVariant.capitalize()}UnitTest.exec" | |
} | |
} |
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
apply plugin: 'org.sonarqube' | |
sonarqube { | |
properties { | |
property "sonar.projectVersion", app_version | |
property "sonar.sourceEncoding", "UTF-8" | |
property "sonar.sources", "src/main/java" | |
property "sonar.tests", "src/test/java" | |
property "sonar.dynamicAnalysis", "reuseReports" | |
property 'sonar.java.coveragePlugin', 'jacoco' | |
property 'sonar.coverage.exclusions', excludeFileFilter.join(',') | |
property "sonar.scm.provider", "git" | |
} | |
} |
Hi @anton46 @esafirm
The issue is resolved now
Thank you for the suggestion
After did the changes (implement the suggested approach), the problem is the path and there are some deprecated properties in sonar
sonarqube {
//read the flavor from properties.
def flavorName = "flavorUnsigned"
def variant = "debug"
androidVariant flavorName + variant.capitalize() --------> //outside
properties {
...
property 'sonar.binaries', "build/tmp/kotlin-classes/$androidVariant" --------> //inside
property "sonar.libraries", libraries
...
property 'sonar.junit.reportsPaths', "build/test-results/test${androidVariant.capitalize()}UnitTest"
property 'sonar.jacoco.reportPaths', "build/jacoco/test${androidVariant.capitalize()}UnitTest.exec"
}
}
- Path issue: the
androidVariant
inside thepropery{}
is different with the outsideandroidVariant
- Deprecated property:
sonar.jacoco.reportPaths
has been deprecated and changed tosonar.coverage.jacoco.xmlReportPaths
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I haven't tried it yet, but i think the principle is the same.
Also, you could configure it to apply your gradle files to all your
subprojects