Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

feat: Adds jacoco #1621

Merged
merged 16 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions android/beagle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'de.mannodermaus.android-junit5'
apply plugin: 'kotlin-parcelize'
apply plugin: "org.jetbrains.dokka"
apply from: "$rootDir/jacoco-android.gradle"

android {
compileSdkVersion Dependencies.Versions.compileSdk
Expand All @@ -40,9 +41,6 @@ android {
}

buildTypes {
debug {
testCoverageEnabled true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
Expand Down
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
classpath "com.vanniktech:gradle-maven-publish-plugin:0.15.1"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.6.2.0"
classpath "com.hiya:jacoco-android:0.2"
}
}

Expand Down
1 change: 1 addition & 0 deletions android/internal-processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import br.com.zup.beagle.Dependencies

apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
apply from: "$rootDir/../jacoco.gradle"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
33 changes: 33 additions & 0 deletions android/jacoco-android.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: 'com.hiya.jacoco-android'

jacoco {
toolVersion = '0.8.7'
}

jacocoAndroidUnitTestReport {

csv.enabled false
html.enabled true
xml.enabled true
matheusribeirozup marked this conversation as resolved.
Show resolved Hide resolved
}

tasks.withType(Test) {
useJUnitPlatform()
jacoco.includeNoLocationClasses = true
}
1 change: 1 addition & 0 deletions android/preview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import br.com.zup.beagle.Dependencies
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'de.mannodermaus.android-junit5'
apply from: "$rootDir/jacoco-android.gradle"

android {
compileSdkVersion Dependencies.Versions.compileSdk
Expand Down
1 change: 1 addition & 0 deletions android/processor-shared-code/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import br.com.zup.beagle.Dependencies

apply plugin: 'kotlin'
apply from: "$rootDir/../jacoco.gradle"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
1 change: 1 addition & 0 deletions android/processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import br.com.zup.beagle.Dependencies

apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
apply from: "$rootDir/../jacoco.gradle"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
1 change: 1 addition & 0 deletions backend/framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import br.com.zup.beagle.Dependencies

apply plugin: "org.jetbrains.dokka"
apply from: "$rootDir/../jacoco.gradle"

dependencies {
implementation Dependencies.GeneralLibraries.jacksonKotlin
Expand Down
1 change: 1 addition & 0 deletions backend/kotlin-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import br.com.zup.beagle.Dependencies

apply plugin: "org.jetbrains.dokka"
apply from: rootProject.file('../maven-publish.gradle')
apply from: "$rootDir/../jacoco.gradle"

test {
useJUnitPlatform()
Expand Down
1 change: 1 addition & 0 deletions backend/processor-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import br.com.zup.beagle.Dependencies
apply from: "$rootDir/../jacoco.gradle"

dependencies {
implementation Dependencies.GeneralLibraries.kotlinPoet
Expand Down
1 change: 1 addition & 0 deletions backend/processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import br.com.zup.beagle.Dependencies

apply plugin: 'kotlin-kapt'
apply from: "$rootDir/../jacoco.gradle"

dependencies {
implementation Dependencies.GeneralLibraries.kotlinPoet
Expand Down
1 change: 1 addition & 0 deletions backend/starters/micronaut/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import br.com.zup.beagle.Dependencies

apply plugin: "org.jetbrains.dokka"
apply plugin: 'kotlin-kapt'
apply from: "$rootDir/../jacoco.gradle"

dependencies {
implementation Dependencies.GeneralLibraries.kotlinReflect
Expand Down
1 change: 1 addition & 0 deletions backend/starters/spring/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import br.com.zup.beagle.Dependencies

apply plugin: "org.jetbrains.dokka"
apply from: "$rootDir/../jacoco.gradle"

dependencies {
implementation Dependencies.SpringLibraries.autoconfigure
Expand Down
2 changes: 1 addition & 1 deletion backend/widgets-dsl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import br.com.zup.beagle.Dependencies

apply from: "$rootDir/../jacoco.gradle"
dependencies {
api project(Dependencies.Modules.widgets)
}
Expand Down
1 change: 1 addition & 0 deletions backend/widgets/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

apply plugin: "org.jetbrains.dokka"
apply from: "$rootDir/../jacoco.gradle"

import br.com.zup.beagle.Dependencies

Expand Down
4 changes: 2 additions & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ end
platform :android do
desc "Pull Request verification"
lane :pull_request_verification do
gradle(project_dir: "android", task: "clean detekt lintDebug test")
gradle(project_dir: "android", task: "clean detekt lintDebug jacocoTestReportDebug")
gradle(project_dir: "android", task: "sample:assembleDebug sample:assembleDebugAndroidTest")
end

Expand Down Expand Up @@ -196,7 +196,7 @@ platform :backend do
desc "Pull Request verification"
lane :pull_request_verification do
gradle(project_dir: "backend", task: "detekt")
gradle(project_dir: "backend", tasks:["clean", "assemble", "test"])
gradle(project_dir: "backend", tasks:["clean", "assemble", "jacocoTestReportDebug"])
end

desc "Sync Spring BFF sample to Micronaut BFF sample"
Expand Down
71 changes: 71 additions & 0 deletions jacoco.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: 'jacoco'

jacoco {
toolVersion = '0.8.7'
}

def fileFilter = ['**/R.class',
'**/R$*x.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'**/*$*',
'android/**/*.*',
'**/*Function*',
'**/*_impl*',
'**/*.DefaultImpls.*',
'**/beagle/view/*.class']

task jacocoTestReportDebug(type: JacocoReport) {

def kotlinSrc = "$project.projectDir/src/main/kotlin"
def javaSrc = "$project.projectDir/src/main/java"
def javaClasses = fileTree(dir: "$project.buildDir/intermediates/javac/debug", excludes: fileFilter)
def kotlinClasses = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
def kotlinLibClasses = fileTree(dir: "$project.buildDir/classes/kotlin/main", excludes: fileFilter)

def dependencyTasks
if (project.plugins.hasPlugin('com.android.application')) {
dependencyTasks = ['testDebugUnitTest']
//FIXME uncomment below this if you want instrumented tests on your report
// dependencyTasks = ['testDebugUnitTest', 'createDebugCoverageReport']
hernandazevedozup marked this conversation as resolved.
Show resolved Hide resolved
} else if (project.plugins.hasPlugin("com.android.library")) {
dependencyTasks = ['testDebugUnitTest']
} else {
dependencyTasks = ['test']
}

dependsOn {
dependencyTasks
}

reports {
xml.enabled = true
html.enabled = true
}

getSourceDirectories().setFrom([javaSrc, kotlinSrc])
getClassDirectories().setFrom([javaClasses, kotlinClasses, kotlinLibClasses])
getExecutionData().setFrom([fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'jacoco/test.exec', 'outputs/code-coverage/connected/**/*.ec'
])], [fileTree(dir: "${System.env.VDTESTING_DOWNLOADED_FILES_DIR}", includes: [
'*sdcard_coverage.ec'
])])

}