diff --git a/build.gradle b/build.gradle index a222e170..57530186 100755 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,14 @@ buildscript { - ext.kotlin_version = '1.2.41' + ext.kotlin_version = '1.3.21' repositories { google() jcenter() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.1' + classpath 'com.android.tools.build:gradle:3.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'org.jacoco:org.jacoco.core:0.8.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c471b180..fc3741ee 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon May 07 20:12:54 CEST 2018 +#Thu Feb 28 08:10:16 CET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/library/build.gradle b/library/build.gradle index 1488008b..eb0e59eb 100755 --- a/library/build.gradle +++ b/library/build.gradle @@ -3,12 +3,20 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'jacoco' group='com.github.Constructor-io' +jacoco { + toolVersion = '0.8.3' +} + +tasks.withType(Test) { + jacoco.includeNoLocationClasses = true +} + android { - compileSdkVersion 27 - buildToolsVersion '27.0.3' + compileSdkVersion 28 dexOptions { maxProcessCount 4 @@ -17,7 +25,7 @@ android { defaultConfig { minSdkVersion 19 - targetSdkVersion 27 + targetSdkVersion 28 testInstrumentationRunner "${applicationId}.runner.RxAndroidJUnitRunner" versionCode 1 versionName '1.2.0' @@ -88,6 +96,61 @@ android { } +task jacocoUnitTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { + + def buildDir = "build/" + + def coverageSourceDirs = [ + "src/main/java" + ] + + def excludedClasses = [ + '**/databinding/**/*.*', + '**/android/databinding/*Binding.*', + '**/BR.*', + '**/R.*', + '**/R$*.*', + '**/BuildConfig.*', + '**/Manifest*.*', + '**/*_MembersInjector.*', + '**/Dagger*Component.*', + '**/Dagger*Component$Builder.*', + '**/*Module_*Factory.*', + '**/*Fragment*.*', + '**/*Activity*.*', + '**/*Adapter*.*', + '**/*ViewPager*.*', + '**/*ViewHolder*.*', + '**/*Module*.*' + ] + + def javaClasses = fileTree( + dir: "$buildDir/intermediates/classes/debug", + excludes: excludedClasses + ) + + def kotlinClasses = fileTree( + dir: "$buildDir/tmp/kotlin-classes/debug", + excludes: excludedClasses + ) + + classDirectories = files([ javaClasses ], [ kotlinClasses ]) + additionalSourceDirs = files(coverageSourceDirs) + sourceDirectories = files(coverageSourceDirs) + executionData = fileTree(dir: "$buildDir/jacoco", includes: [ + "testDebugUnitTest.exec" + ]) + + reports { + xml.enabled = true + html.enabled = true + } +} + +task getCoverage(type: Exec, dependsOn: 'jacocoUnitTestReport') { + group = "Reporting" + commandLine "open", "$buildDir/reports/jacoco/jacocoUnitTestReport/html/index.html" +} apply from: 'dependencies.gradle' @@ -104,8 +167,8 @@ dependencies { implementation supportLibs implementation networkLibs implementation otherLibs - implementation 'com.android.support:support-v4:27.1.1' - implementation 'com.android.support:cardview-v7:27.1.1' + implementation 'com.android.support:support-v4:28.0.0' + implementation 'com.android.support:cardview-v7:28.0.0' kapt annotationProcessorLibs kaptTest daggerCompiler kaptAndroidTest daggerCompiler diff --git a/library/dependencies.gradle b/library/dependencies.gradle index 41fd1ae9..fc99e893 100755 --- a/library/dependencies.gradle +++ b/library/dependencies.gradle @@ -1,6 +1,6 @@ ext { versions = [ - support : "27.1.1", + support : "28.0.0", moshi : "1.5.0", okHttp : "3.9.0", retrofit: '2.3.0', diff --git a/library/src/main/java/io/constructor/features/base/BaseActivity.kt b/library/src/main/java/io/constructor/features/base/BaseActivity.kt index 0677d23d..e98c0088 100755 --- a/library/src/main/java/io/constructor/features/base/BaseActivity.kt +++ b/library/src/main/java/io/constructor/features/base/BaseActivity.kt @@ -13,15 +13,6 @@ import io.constructor.injection.module.ActivityModule import io.constructor.util.d import java.util.concurrent.atomic.AtomicLong -/** - * Abstract activity that every other Activity in this application must implement. It provides the - * following functionality: - * - Handles creation of Dagger components and makes sure that instances of - * ConfigPersistentComponent are kept across configuration changes. - * - Set up and handles a GoogleApiClient instance that can be used to access the Google sign in - * api. - * - Handles signing out when an authentication error event is received. - */ abstract class BaseActivity : AppCompatActivity() { private var activityComponent: ActivityComponent? = null @@ -48,7 +39,7 @@ abstract class BaseActivity : AppCompatActivity() { componentsArray.put(activityId, configPersistentComponent) } else { d("Reusing ConfigPersistentComponent id=${activityId}") - configPersistentComponent = componentsArray.get(activityId) + configPersistentComponent = componentsArray.get(activityId)!! } activityComponent = configPersistentComponent.activityComponent(ActivityModule(this)) activityComponent?.inject(this) diff --git a/sample/build.gradle b/sample/build.gradle index ad4401e4..35ddde42 100755 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 27 + compileSdkVersion 28 defaultConfig { applicationId "io.constructor.sample" minSdkVersion 19 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -22,7 +22,6 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - buildToolsVersion '27.0.3' } configurations.all { @@ -36,9 +35,9 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation project(':library') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support:recyclerview-v7:27.1.1' - implementation "com.android.support:cardview-v7:27.1.1" - implementation 'com.android.support.constraint:constraint-layout:1.1.0' + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support:recyclerview-v7:28.0.0' + implementation "com.android.support:cardview-v7:28.0.0" + implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' }