From 5dcf253585fb476f3064a8e72ce74e02e9689a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Antonio=20D=C3=ADaz-Benito=20Soriano?= Date: Fri, 5 Jan 2018 12:34:59 +0100 Subject: [PATCH] Espresso 3 (#89) * Gradle version updates * Gradle plugin 3.1.0-alpha06 * Espresso 3 * Static analysis fixes * Workaround for Travis problems with Android 27 * ProGuard fixes --- .travis.yml | 6 ++++-- app/build.gradle | 18 +++++++++--------- app/proguard-rules.pro | 3 +++ .../TopGamingActivityInstrumentation.kt | 19 +++++++------------ app/src/main/kotlin/app/MainApplication.kt | 2 ++ .../kotlin/app/common/OutScalingImageView.kt | 4 ++-- build.gradle | 9 +++++---- buildsystem/dependencies.gradle | 4 ++-- ci/release.sh | 2 +- data/build.gradle | 12 ++++++------ .../main/kotlin/data/top/TopRequestSource.kt | 2 ++ domain/build.gradle | 6 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- hooks/pre-push | 2 +- util-android-test/build.gradle | 8 ++++---- util-android/build.gradle | 6 +++--- 16 files changed, 55 insertions(+), 50 deletions(-) diff --git a/.travis.yml b/.travis.yml index 90d2a2e..04b260d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,12 @@ android: components: - tools - platform-tools - - android-26 - - build-tools-26.0.1 + - android-27 + - build-tools-27.0.3 - extra-android-m2repository - extra-google-m2repository +before_install: + - yes | sdkmanager "platforms;android-27" branches: except: - "/^[0-9]/" diff --git a/app/build.gradle b/app/build.gradle index e3850cd..3aa0612 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ android { buildToolsVersion rootProject.ext.androidBuildToolsVersion signingConfigs { release { - storeFile new File("dummy12.keystore") + storeFile new File(rootProject.projectDir.absolutePath + File.separator + "dummy12.keystore") storePassword "dummy12" keyAlias "dummy12" keyPassword "dummy12" @@ -63,19 +63,19 @@ repositories { maven { url "https://maven.google.com" } } dependencies { - compile project(':data') - compile project(':domain') - compile project(':util-android') - androidTestCompile project(':util-android-test') + implementation project(':data') + implementation project(':domain') + implementation project(':util-android') + androidTestImplementation project(':util-android-test') rootProject.ext.androidTestCompileAppDependencies.forEach { - androidTestCompile(it) { + androidTestImplementation(it) { exclude group: 'com.google.code.findbugs' exclude module: 'support-annotations' } } kapt rootProject.ext.annotationProcessorAppDependencies kaptAndroidTest rootProject.ext.annotationProcessorAndroidTestAppDependencies - compile rootProject.ext.compileDependencies - compile rootProject.ext.compileAppDependencies - testCompile rootProject.ext.testCompileDependencies + implementation rootProject.ext.compileDependencies + implementation rootProject.ext.compileAppDependencies + testImplementation rootProject.ext.testCompileDependencies } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 4dfed71..830abb4 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -21,3 +21,6 @@ -dontwarn com.google.errorprone.annotations.* -dontwarn com.squareup.okhttp.** -keep class android.support.v7.widget.SearchView { *; } +-dontnote io.reactivex.** +-dontnote org.reactivestreams.** +-dontwarn io.reactivex.internal.** diff --git a/app/src/androidTest/kotlin/app/gaming/TopGamingActivityInstrumentation.kt b/app/src/androidTest/kotlin/app/gaming/TopGamingActivityInstrumentation.kt index daa1e16..d3672d7 100644 --- a/app/src/androidTest/kotlin/app/gaming/TopGamingActivityInstrumentation.kt +++ b/app/src/androidTest/kotlin/app/gaming/TopGamingActivityInstrumentation.kt @@ -5,20 +5,15 @@ import android.app.Instrumentation import android.support.test.InstrumentationRegistry import android.support.test.espresso.Espresso import android.support.test.espresso.Espresso.onView +import android.support.test.espresso.IdlingRegistry import android.support.test.espresso.NoActivityResumedException import android.support.test.espresso.action.ViewActions.click import android.support.test.espresso.assertion.ViewAssertions.matches import android.support.test.espresso.intent.Intents import android.support.test.espresso.intent.Intents.intended import android.support.test.espresso.intent.Intents.intending -import android.support.test.espresso.intent.matcher.IntentMatchers.anyIntent -import android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent -import android.support.test.espresso.intent.matcher.IntentMatchers.hasExtra -import android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom -import android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed -import android.support.test.espresso.matcher.ViewMatchers.isDisplayed -import android.support.test.espresso.matcher.ViewMatchers.withId -import android.support.test.espresso.matcher.ViewMatchers.withText +import android.support.test.espresso.intent.matcher.IntentMatchers.* +import android.support.test.espresso.matcher.ViewMatchers.* import android.support.test.rule.ActivityTestRule import android.support.v7.widget.Toolbar import android.view.View @@ -51,12 +46,12 @@ internal class TopGamingActivityInstrumentation { TopGamingAllTimePostsActivity::class.java, false, false) { override fun beforeActivityLaunched() { IDLING_RESOURCE = BinaryIdlingResource("load") - Espresso.registerIdlingResources(IDLING_RESOURCE) + IdlingRegistry.getInstance().register(IDLING_RESOURCE) } override fun afterActivityFinished() { super.afterActivityFinished() - Espresso.unregisterIdlingResources(IDLING_RESOURCE) + IdlingRegistry.getInstance().unregister(IDLING_RESOURCE) } } @JvmField @@ -153,8 +148,8 @@ internal class TopGamingActivityInstrumentation { /** * Launches the activity. */ - private fun launchActivity() = activityTestRule.launchActivity( - TopGamingAllTimePostsActivity.getCallingIntent(InstrumentationRegistry.getContext())) + private fun launchActivity() = activityTestRule.launchActivity(TopGamingAllTimePostsActivity + .getCallingIntent(InstrumentationRegistry.getTargetContext())) companion object { private lateinit var IDLING_RESOURCE: BinaryIdlingResource diff --git a/app/src/main/kotlin/app/MainApplication.kt b/app/src/main/kotlin/app/MainApplication.kt index ce7f4ff..4861bff 100644 --- a/app/src/main/kotlin/app/MainApplication.kt +++ b/app/src/main/kotlin/app/MainApplication.kt @@ -1,5 +1,6 @@ package app +import android.annotation.SuppressLint import android.app.Application import android.support.v7.widget.RecyclerView import android.view.View @@ -17,6 +18,7 @@ import domain.Domain /** * Custom application. */ +@SuppressLint("Registered") // Registered via buildType-specific manifests internal open class MainApplication : Application() { override fun onCreate() { super.onCreate() diff --git a/app/src/main/kotlin/app/common/OutScalingImageView.kt b/app/src/main/kotlin/app/common/OutScalingImageView.kt index 3724c66..c9203a0 100644 --- a/app/src/main/kotlin/app/common/OutScalingImageView.kt +++ b/app/src/main/kotlin/app/common/OutScalingImageView.kt @@ -1,9 +1,9 @@ package app.common import android.content.Context +import android.support.v7.widget.AppCompatImageView import android.util.AttributeSet import android.view.View -import android.widget.ImageView /** @@ -12,7 +12,7 @@ import android.widget.ImageView * ScalingImageView */ internal class OutScalingImageView(context: Context, attrs: AttributeSet?) - : ImageView(context, attrs) { + : AppCompatImageView(context, attrs) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { var localHeightMeasureSpec = heightMeasureSpec val mDrawable = drawable diff --git a/build.gradle b/build.gradle index 33650d3..789e7c7 100644 --- a/build.gradle +++ b/build.gradle @@ -4,10 +4,11 @@ apply from: 'buildsystem/dependencies.gradle' buildscript { repositories { + google() jcenter() maven { url "https://plugins.gradle.org/m2/" } } - final def androidPluginVersion = "2.3.2" + final def androidPluginVersion = "3.1.0-alpha06" final def kotlinPluginVersion = rootProject.ext.kotlinVersion = "1.1.4" final def dokkaPluginVersion = "0.9.15" final def ktLintGradlePluginVersion = "1.3.0" @@ -27,10 +28,10 @@ final def inducedVersion = System.getenv("ARTIFACT_VERSION") final def staticAnalysisReportFolderTarget = project.rootDir.absolutePath + "/staticAnalysisReport" rootProject.ext { - androidCompileSdkVersion = 26 + androidCompileSdkVersion = 27 androidMinSdkVersion = 14 - androidTargetSdkVersion = 26 - androidBuildToolsVersion = '26.0.1' + androidTargetSdkVersion = 27 + androidBuildToolsVersion = '27.0.3' androidVersionCode = inducedVersion != null ? Integer.parseInt(inducedVersion) : 1 // Depending on the git method locally causes IDE issues androidVersionName = String.valueOf(androidVersionCode) androidTestInstrumentationRunner = "app.AndroidTestApplicationAndroidJUnitRunner" diff --git a/buildsystem/dependencies.gradle b/buildsystem/dependencies.gradle index 2a8fc66..2844d94 100644 --- a/buildsystem/dependencies.gradle +++ b/buildsystem/dependencies.gradle @@ -1,5 +1,5 @@ final def daggerVersion = "2.11" -final def espressoVersion = "2.2.2" +final def espressoVersion = "3.0.1" final def jsr250Version = "1.0" final def junitPlatformRunnerVersion = "1.0.0-M3" final def jUnitVersion = "4.12" @@ -13,7 +13,7 @@ final def rxAndroidVersion = "2.0.1" final def rxJavaVersion = "2.1.3" final def spekVersion = "1.1.0-beta2" final def storeVersion = "3.0.0-beta" -final def supportVersion = "26.0.1" +final def supportVersion = "27.0.2" ext { compileDependencies = [ diff --git a/ci/release.sh b/ci/release.sh index c255e62..a31aa95 100755 --- a/ci/release.sh +++ b/ci/release.sh @@ -39,7 +39,7 @@ uploadReleaseToGitHub() { # Build the apk ./gradlew assembleRelease # Copy it out of its cave - cp app/build/outputs/apk/app-release.apk . + cp app/build/outputs/apk/release/app-release.apk . # Attach the artifact curl -D - \ diff --git a/data/build.gradle b/data/build.gradle index 7327c59..16a0a77 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -44,16 +44,16 @@ repositories { } dependencies { - compile project(':domain') - compile project(':util-android') + implementation project(':domain') + implementation project(':util-android') kapt rootProject.ext.annotationProcessorDataDependencies kaptTest rootProject.ext.annotationProcessorTestDataDependencies - provided rootProject.ext.providedDataDependencies - compile rootProject.ext.compileDependencies + compileOnly rootProject.ext.providedDataDependencies + implementation rootProject.ext.compileDependencies rootProject.ext.compileDataDependencies.forEach { - compile(it) { + implementation(it) { exclude group: 'io.reactivex' } } - testCompile rootProject.ext.testCompileDependencies + testImplementation rootProject.ext.testCompileDependencies } diff --git a/data/src/main/kotlin/data/top/TopRequestSource.kt b/data/src/main/kotlin/data/top/TopRequestSource.kt index c647416..cbc8bdb 100644 --- a/data/src/main/kotlin/data/top/TopRequestSource.kt +++ b/data/src/main/kotlin/data/top/TopRequestSource.kt @@ -41,6 +41,7 @@ internal class TopRequestSource { topRequestParameters) .onErrorResumeNext { store.get(topRequestParameters) }) } else { + // noinspection CheckResult - False positive Single.just(TopRequestDataContainer.EMPTY) } @@ -53,6 +54,7 @@ internal class TopRequestSource { if (pageMap[topRequestParameters.page] != NO_MORE_PAGES) { updatePageMapAndContinue(topRequestParameters.page, store.get(topRequestParameters)) } else { + // noinspection CheckResult - False positive Single.just(TopRequestDataContainer.EMPTY) } diff --git a/domain/build.gradle b/domain/build.gradle index e10ebc9..04ba8a2 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -8,7 +8,7 @@ repositories { dependencies { compileOnly rootProject.ext.compileOnlyDomainDependencies - compile rootProject.ext.compileDependencies - compile rootProject.ext.compileDomainDependencies - testCompile rootProject.ext.testCompileDependencies + implementation rootProject.ext.compileDependencies + implementation rootProject.ext.compileDomainDependencies + testImplementation rootProject.ext.testCompileDependencies } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bf1b63c..57c7d2d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip diff --git a/hooks/pre-push b/hooks/pre-push index b36d264..dcfbf1d 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -1,5 +1,5 @@ ./gradlew --refresh-dependencies -x :app:validateSigningRelease -x :app:packageRelease clean check assemble test cAT || { exit 1; } adb uninstall org.jorge.ms.app.debug -adb install app/build/outputs/apk/app-debug.apk +adb install app/build/outputs/apk/debug/app-debug.apk adb shell monkey -p org.jorge.ms.app.debug -v 500 adb uninstall org.jorge.ms.app.debug diff --git a/util-android-test/build.gradle b/util-android-test/build.gradle index 0196827..c0c2d5f 100644 --- a/util-android-test/build.gradle +++ b/util-android-test/build.gradle @@ -42,13 +42,13 @@ repositories { } dependencies { - compile rootProject.ext.compileDependencies - compile rootProject.ext.providedUtilAndroidDependencies + implementation rootProject.ext.compileDependencies + compileOnly rootProject.ext.providedUtilAndroidDependencies rootProject.ext.compileUtilAndroidTestDependencies.forEach { - compile(it) { + api(it) { exclude group: 'com.google.code.findbugs' exclude module: 'support-annotations' } } - testCompile rootProject.ext.testCompileDependencies + testImplementation rootProject.ext.testCompileDependencies } diff --git a/util-android/build.gradle b/util-android/build.gradle index 766198c..09c54ef 100644 --- a/util-android/build.gradle +++ b/util-android/build.gradle @@ -42,7 +42,7 @@ repositories { } dependencies { - compile rootProject.ext.compileDependencies - compile rootProject.ext.providedUtilAndroidDependencies - testCompile rootProject.ext.testCompileDependencies + implementation rootProject.ext.compileDependencies + compileOnly rootProject.ext.providedUtilAndroidDependencies + testImplementation rootProject.ext.testCompileDependencies }