Skip to content

Commit

Permalink
Update build dependencies + Use task configuration avoidance api (#215)
Browse files Browse the repository at this point in the history
* Use lazy configuration task api

* Update `gradle-scalates` dependency to 0.29

* Update kotlin-gradle-plugin to 1.4.32

* Remove unused repositories from root build.gradle

* Bump scala 2.12 dependencies

* Bump AGP dependency and switch to compileOnly to avoid upgrading AGP version in consumers

* Update shot-android dependencies

* Use lazy tasks api in ShotPlugin

* Update ktlint-gradle plugin to recent version.

Update requires using AGP version>4.0 which then requires using `androidx` dependencies

* Update shot-android dependencies

* Fix reported Android Lint issues

* Fix bad merge

Co-authored-by: Pedro Vicente Gómez Sánchez <pedrovgs@users.noreply.github.com>
Co-authored-by: Pedro Gómez <pedro@karumi.com>
  • Loading branch information
3 people authored Apr 14, 2021
1 parent 5ef5422 commit 0002350
Show file tree
Hide file tree
Showing 19 changed files with 102 additions and 86 deletions.
12 changes: 5 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
google()
jcenter()
}

ext.kotlin_version = "1.4.21"
ext.kotlin_version = "1.4.32"

dependencies {
classpath "gradle.plugin.com.github.maiflai:gradle-scalatest:0.25"
classpath "gradle.plugin.com.github.maiflai:gradle-scalatest:0.29"
classpath "cz.alenkacz:gradle-scalafmt:1.14.0"
classpath "com.android.tools.build:gradle:3.4.3"
classpath "com.android.tools.build:gradle:4.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:9.4.1"
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.0.0"
}
}
}
17 changes: 9 additions & 8 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ repositories {
}

dependencies {
implementation 'org.scala-lang:scala-library:2.12.11'
implementation 'org.scala-lang.modules:scala-xml_2.12:1.0.6'
implementation 'org.scala-lang:scala-library:2.12.13'
implementation 'org.scala-lang.modules:scala-xml_2.12:1.3.0'
implementation 'com.sksamuel.scrimage:scrimage-core_2.12:2.1.8'
implementation 'org.freemarker:freemarker:2.3.23'
implementation 'org.json4s:json4s-native_2.12:3.5.3'
implementation 'org.freemarker:freemarker:2.3.31'
implementation 'io.github.bitstorm:tinyzip-core:1.0.0'
implementation 'org.json4s:json4s-jackson_2.12:3.6.10'
testImplementation 'org.scalatest:scalatest_2.12:3.0.3'
testRuntime 'org.pegdown:pegdown:1.4.2'
implementation 'org.json4s:json4s-native_2.12:3.6.11'
implementation 'org.json4s:json4s-jackson_2.12:3.6.11'

testImplementation 'org.scalatest:scalatest_2.12:3.2.6'
testRuntimeOnly "com.vladsch.flexmark:flexmark-profile-pegdown:0.36.8" // https://github.com/scalatest/scalatest/issues/1736
testImplementation 'org.scalamock:scalamock-scalatest-support_2.12:3.5.0'
}

sourceSets {
test {
output.resourcesDir = "build/classes/test/resources"
}
}
}
12 changes: 9 additions & 3 deletions core/src/test/scala/com/karumi/shot/ShotSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ import com.karumi.shot.screenshots.{
import com.karumi.shot.system.EnvVars
import com.karumi.shot.ui.Console
import org.scalamock.scalatest.MockFactory
import org.scalatest.{BeforeAndAfter, FlatSpec, Matchers}

import org.scalatest.BeforeAndAfter
import org.scalatest.flatspec._
import org.scalatest.matchers._
import java.io.File
import java.util

class ShotSpec extends FlatSpec with Matchers with BeforeAndAfter with MockFactory with Resources {
class ShotSpec
extends AnyFlatSpec
with should.Matchers
with BeforeAndAfter
with MockFactory
with Resources {

private var shot: Shot = _
private val adb = mock[Adb]
Expand Down
5 changes: 3 additions & 2 deletions core/src/test/scala/com/karumi/shot/domain/ConfigSpec.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.karumi.shot.domain

import com.karumi.shot.mothers.BuildTypeMother
import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.flatspec._
import org.scalatest.matchers._

class ConfigSpec extends FlatSpec with Matchers {
class ConfigSpec extends AnyFlatSpec with should.Matchers {

"Config" should "use the screenshot tests library implemented by Facebook" in {
Config.androidDependency shouldBe "com.karumi:shot-android:5.10.4-SNAPSHOT"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.karumi.shot.xml

import com.karumi.shot.Resources
import com.karumi.shot.domain.Config
import com.karumi.shot.xml.ScreenshotsSuiteXmlParser._
import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.flatspec._
import org.scalatest.matchers._

class ScreenshotsSuiteXmlParserSpec extends FlatSpec with Matchers with Resources {
class ScreenshotsSuiteXmlParserSpec extends AnyFlatSpec with should.Matchers with Resources {

private val anyScreenshotsFolder = "/screenshots/"
private val anyTemporalScreenshotsFolder =
Expand Down
9 changes: 4 additions & 5 deletions release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ afterEvaluate { project ->

def isAndroidProject = project.getPlugins().hasPlugin('com.android.application') || project.getPlugins().hasPlugin('com.android.library')
if (isAndroidProject) {
task androidSourcesJar(type: Jar) {
tasks.register('androidSourcesJar', Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
Expand All @@ -91,12 +91,12 @@ afterEvaluate { project ->
archives androidSourcesJar
}
} else {
task javadocJar(type: Jar) {
tasks.register('javadocJar', Jar) {
classifier = 'javadoc'
from javadoc
}

task sourcesJar(type: Jar) {
tasks.register('sourcesJar', Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
Expand All @@ -105,5 +105,4 @@ afterEvaluate { project ->
archives javadocJar, sourcesJar
}
}

}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':shot', ':core', ':shot-android'
include ':shot', ':core', ':shot-android'
21 changes: 13 additions & 8 deletions shot-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,20 @@ repositories {
mavenCentral()
mavenLocal()
google()
jcenter()
maven { url 'https://jitpack.io' }
exclusiveContent {
forRepository { jcenter() }
filter {
includeModule("org.jetbrains.kotlinx", "kotlinx-collections-immutable-jvm")
includeGroup("org.jetbrains.trove4j")
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.facebook.testing.screenshot:core:0.13.0"
implementation "androidx.test:runner:1.3.0"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.recyclerview:recyclerview:1.2.0"
implementation "androidx.test.espresso:espresso-core:3.3.0"
implementation "androidx.compose.ui:ui-test-junit4:1.0.0-beta03"
implementation "com.google.code.gson:gson:2.8.6"
Expand All @@ -58,10 +63,10 @@ dependencies {
//noinspection FragmentGradleConfiguration
implementation "androidx.fragment:fragment-testing:1.3.2"

testImplementation "junit:junit:4.13"
testImplementation "org.mockito:mockito-core:2.28.2"
testImplementation "junit:junit:4.13.2"
testImplementation "org.mockito:mockito-core:3.9.0"
testImplementation "com.nhaarman:mockito-kotlin:1.6.0"
testImplementation "org.robolectric:robolectric:4.4"
testImplementation "org.robolectric:robolectric:4.5.1"
testImplementation "androidx.test.ext:junit:1.1.2"
testImplementation "androidx.test:runner:1.3.0"
testImplementation "androidx.test:rules:1.3.0"
Expand All @@ -83,6 +88,6 @@ dependencies {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
freeCompilerArgs += ["-Xskip-prerelease-check"]
}
}
}
3 changes: 2 additions & 1 deletion shot-android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
POM_NAME=Shot Android Companion Library
POM_ARTIFACT_ID=shot-android
POM_PACKAGING=aar
POM_PACKAGING=aar
android.useAndroidX=true
6 changes: 2 additions & 4 deletions shot-android/src/main/java/com/karumi/shot/KeyboardCloser.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.karumi.shot

import android.R
import android.app.Activity
import android.graphics.Rect
import android.os.Build
Expand All @@ -20,8 +19,7 @@ interface KeyboardCloser {
val focusedView = activity.currentFocus
if (focusedView != null) {
activity.runOnUiThread {
val imm: InputMethodManager =
activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
val imm: InputMethodManager = activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(focusedView.windowToken, 0)
}
}
Expand All @@ -32,7 +30,7 @@ interface KeyboardCloser {
throw IllegalStateException("We couldn't close they keyboard after 5 retries.")
}
closeKeyboard(activity)
val rootView = activity.findViewById<View>(R.id.content).rootView
val rootView = activity.findViewById<View>(android.R.id.content).rootView
val measuredRect = Rect()
rootView.rootView.getWindowVisibleDisplayFrame(measuredRect)
val rootViewHeight = measuredRect.bottom - measuredRect.top
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public AndroidStoragePermissions(Instrumentation instrumentation) {
public void checkPermissions() {
Context testAppContext = instrumentation.getContext();
for (String permission : REQUIRED_PERMISSIONS) {
if ((permission.equals(READ_PERMISSION) && Build.VERSION.SDK_INT < 16)
|| testAppContext.checkCallingOrSelfPermission(permission)
== PackageManager.PERMISSION_GRANTED) {
if (testAppContext.checkCallingOrSelfPermission(permission) == PackageManager.PERMISSION_GRANTED) {
continue;
}
if (Build.VERSION.SDK_INT < 23) {
Expand Down
4 changes: 2 additions & 2 deletions shot-consumer-compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ allprojects {
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
}
35 changes: 17 additions & 18 deletions shot-consumer-flavors/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url uri("../../repo") }
jcenter()
google()
}
dependencies {
classpath "com.neenbedankt.gradle.plugins:android-apt:1.7"
classpath "com.karumi:shot:5.10.4-SNAPSHOT"
classpath "com.trevjonez.composer:plugin:1.0.0-rc08"
}
repositories {
gradlePluginPortal()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url uri("../../repo") }
jcenter()
google()
}
dependencies {
classpath "com.neenbedankt.gradle.plugins:android-apt:1.7"
classpath "com.karumi:shot:5.10.4-SNAPSHOT"
classpath "com.trevjonez.composer:plugin:1.0.0-rc08"
}
}

apply plugin: "com.android.application"
Expand Down Expand Up @@ -99,25 +99,24 @@ dependencies {
androidTestImplementation "net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.0.0"
}

task ktlint(type: JavaExec) {
tasks.register("ktlint", JavaExec) {
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
}

check.dependsOn ktlint
tasks.named("check") { dependsOn "ktLint" }

task ktlintFormat(type: JavaExec) {
tasks.register("ktlintFormat", JavaExec) {
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).configureEach {
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]
}

shot {
showOnlyFailingTestsInReports = true
}

2 changes: 1 addition & 1 deletion shot-consumer-flavors/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ allprojects {
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
8 changes: 4 additions & 4 deletions shot-consumer/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,20 @@ shot {
showOnlyFailingTestsInReports = true
}

task ktlint(type: JavaExec) {
tasks.register("ktlint", JavaExec) {
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
}

check.dependsOn ktlint
tasks.named("check") { dependsOn "ktLint" }

task ktlintFormat(type: JavaExec) {
tasks.register("ktlintFormat", JavaExec) {
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).configureEach {
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]
}
10 changes: 5 additions & 5 deletions shot-consumer/app2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,20 @@ dependencies {
//shotDependencies "com.karumi:shot-android:4.2.0"
}

task ktlint(type: JavaExec) {
tasks.register("ktlint", JavaExec) {
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
}

check.dependsOn ktlint
tasks.named("check") { dependsOn "ktLint" }

task ktlintFormat(type: JavaExec) {
tasks.register("ktlintFormat", JavaExec) {
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).configureEach {
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]
}
}
2 changes: 1 addition & 1 deletion shot-consumer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ allprojects {
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
Loading

0 comments on commit 0002350

Please sign in to comment.