Skip to content

Commit

Permalink
update lib versions.
Browse files Browse the repository at this point in the history
update gradle wrapper.
remove settling task(seg faults were caused a by a version mismatch of libraries in both app/test apks).
roll version to 0.5.0
  • Loading branch information
trevjonez committed Jul 14, 2018
1 parent 374661d commit e3c489f
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 91 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In the appropriate `build.gradle` file(s):
1. Add the jitpack maven repository and classpath dependency.
```groovy
buildscript {
ext.kontrast_version = '0.4.0'
ext.kontrast_version = '0.5.0'
repositories {
maven { url "https://jitpack.io" }
}
Expand Down
10 changes: 5 additions & 5 deletions androidTestClient/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ android {
}

dependencies {
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
compile group: 'com.android.support', name: 'appcompat-v7', version: support_lib_version
compile group: 'com.android.support.test', name: 'rules', version: '1.0.1'
implementation group: 'junit', name: 'junit', version: '4.12'
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
implementation group: 'com.android.support', name: 'appcompat-v7', version: support_lib_version
api group: 'com.android.support.test', name: 'rules', version: '1.0.2'
}

dependencies {
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.8.0'
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.10.0'
}


Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies {
api group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
kapt group: 'com.android.databinding', name: 'compiler', version: android_plugin_version
api group: 'com.android.support', name: 'cardview-v7', version: support_lib_version
api group: 'com.android.support.constraint', name: 'constraint-layout', version: '1.0.2'
api group: 'com.android.support.constraint', name: 'constraint-layout', version: '1.1.2'

androidTestImplementation group: 'junit', name: 'junit', version: '4.12'
}
Expand Down
4 changes: 2 additions & 2 deletions appClient/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ android {
}

dependencies {
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
compile group: 'com.android.support', name: 'appcompat-v7', version: support_lib_version
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
api group: 'com.android.support', name: 'appcompat-v7', version: support_lib_version
}

task sourcesJar(type: Jar) {
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
*/

buildscript {
ext.kotlin_version = '1.2.21'
ext.kotlin_version = '1.2.51'
ext.kotlinx_html_version = '0.6.8'
ext.android_plugin_version = '3.0.1'
ext.support_lib_version = '26.1.0'
ext.android_plugin_version = '3.1.3'
ext.support_lib_version = '27.1.1'
ext.min_sdk = 16
ext.target_sdk = 27

repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://plugins.gradle.org/m2/' }
gradlePluginPortal()
}
dependencies {
classpath group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: kotlin_version
classpath group: 'com.netflix.nebula', name: 'nebula-kotlin-plugin', version: kotlin_version
classpath group: 'com.android.tools.build', name: 'gradle', version: android_plugin_version
classpath group: 'com.github.dcendents', name: 'android-maven-gradle-plugin', version: '1.5'
classpath group: 'com.github.dcendents', name: 'android-maven-gradle-plugin', version: '2.1'
classpath group: 'de.undercouch', name: 'gradle-download-task', version: '3.3.0'
classpath group: 'com.github.trevjonez', name: 'AVD-Gradle-Plugin', version: '0.4.0'
classpath group: 'gradle.plugin.de.fuerstenau', name: 'BuildConfigPlugin', version: '1.1.8'
Expand All @@ -51,4 +51,4 @@ task clean(type: Delete) {
}

group = 'com.github.trevjonez.Kontrast'
version = '0.4.0'
version = '0.5.0'
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
1 change: 1 addition & 0 deletions jvmCommon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

apply plugin: 'java-library'
apply plugin: 'nebula.kotlin'
apply plugin: 'maven'

Expand Down
4 changes: 2 additions & 2 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ gradlePlugin {
dependencies {
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-html-jvm', version: kotlinx_html_version
compile group: 'com.android.tools.build', name: 'gradle', version: android_plugin_version
compile group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.1.5'
compile group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.1.9'
compile group: 'azadev.kotlin', name: 'aza-kotlin-css', version: '1.0'
compile project(':jvmCommon')
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.9.0'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.10.0'
testCompile group: 'commons-io', name: 'commons-io', version: '2.5'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
}
Expand Down
63 changes: 31 additions & 32 deletions plugin/src/main/kotlin/com/trevjonez/kontrast/KontrastPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import com.trevjonez.kontrast.internal.testEvents
import com.trevjonez.kontrast.jvm.FileAdapter
import com.trevjonez.kontrast.jvm.PulledOutput
import com.trevjonez.kontrast.report.TestCaseOutput
import com.trevjonez.kontrast.task.ArtSettlingTask
import com.trevjonez.kontrast.task.CaptureTestKeyTask
import com.trevjonez.kontrast.task.HtmlReportTask
import com.trevjonez.kontrast.task.InstallApkTask
Expand Down Expand Up @@ -102,6 +101,7 @@ class KontrastPlugin : Plugin<Project> {

private fun configureUnzipTask(project: Project, unzipTestTask: Copy) {
val kontrastConfig = project.configurations.findByName(KONTRAST_CONFIG)
?: throw IllegalStateException("Unable to find kontrast configuration")

val unitTestClientJar = kontrastConfig.files.find { it.name.contains("unitTestClient") }

Expand Down Expand Up @@ -159,11 +159,7 @@ class KontrastPlugin : Plugin<Project> {
val mainInstall = createMainInstallTask(project, variant, device)
val testInstall = createTestInstallTask(project, variant, device)

val artSettle = if(device.isEmulator) {
createSettlingTask(project, variant,device, mainInstall, testInstall)
} else null

val render = createRenderTask(project, variant, device, mainInstall, testInstall, artSettle)
val render = createRenderTask(project, variant, device, mainInstall, testInstall)
val keyCapture = createKeyCaptureTask(project, variant, render, device)
val report = createReportTask(project, variant, device)
createTestTask(project, variant, render, keyCapture, unziptestTask, report, device)
Expand All @@ -173,9 +169,11 @@ class KontrastPlugin : Plugin<Project> {

private fun createReportTask(project: Project, variant: ApplicationVariant, targetDevice: AdbDevice): HtmlReportTask {
return project.createTask(type = HtmlReportTask::class,
name = "generate${variant.name.capitalize()}KontrastHtmlReport_${targetDevice.alias ?: targetDevice.id}",
name = "generate${variant.name.capitalize()}KontrastHtmlReport_${targetDevice.alias
?: targetDevice.id}",
description = "Generate HTML test result report").apply {
outputDir = File(project.buildDir, "reports${File.separator}Kontrast${File.separator}${variant.name}${File.separator}${targetDevice.alias ?: targetDevice.id}")
outputDir = File(project.buildDir, "reports${File.separator}Kontrast${File.separator}${variant.name}${File.separator}${targetDevice.alias
?: targetDevice.id}")
variantName = variant.name
deviceAlias = targetDevice.alias ?: targetDevice.id
outputs.upToDateWhen { false }
Expand All @@ -186,7 +184,8 @@ class KontrastPlugin : Plugin<Project> {
keyTask: CaptureTestKeyTask, unzipTestTask: Copy, reportTask: HtmlReportTask,
targetDevice: AdbDevice): Test {
return project.createTask(type = Test::class,
name = "test${variant.name.capitalize()}KontrastTest_${targetDevice.alias ?: targetDevice.id}",
name = "test${variant.name.capitalize()}KontrastTest_${targetDevice.alias
?: targetDevice.id}",
description = "Compare current captured key with render results",
dependsOn = listOf(renderTask, unzipTestTask)).apply {
useJUnit()
Expand All @@ -209,13 +208,15 @@ class KontrastPlugin : Plugin<Project> {
.split("$$")

val inputExtras = try {
adapter.fromJson(buffer(source(File(renderTask.outputsDir, "${names.joinToString(File.separator)}${File.separator}extras.json")))) ?: mapOf()
adapter.fromJson(buffer(source(File(renderTask.outputsDir, "${names.joinToString(File.separator)}${File.separator}extras.json"))))
?: mapOf()
} catch (ignore: FileNotFoundException) {
mapOf<String, String>()
}

val keyExtras = try {
adapter.fromJson(buffer(source(File(keyTask.outputsDir, "${names.joinToString(File.separator)}${File.separator}extras.json")))) ?: mapOf()
adapter.fromJson(buffer(source(File(keyTask.outputsDir, "${names.joinToString(File.separator)}${File.separator}extras.json"))))
?: mapOf()
} catch (ignore: FileNotFoundException) {
mapOf<String, String>()
}
Expand All @@ -239,10 +240,12 @@ class KontrastPlugin : Plugin<Project> {
buffer(source(logcatCaptureFile)).readLines()
.subscribeOn(Schedulers.io())
.skipWhile {
!it.contains("TestRunner: started: ${pulledOutput?.output?.parameterizedName ?: methodName}($className)")
!it.contains("TestRunner: started: ${pulledOutput?.output?.parameterizedName
?: methodName}($className)")
}
.takeUntil {
it.contains("TestRunner: finished: ${pulledOutput?.output?.parameterizedName ?: methodName}($className)")
it.contains("TestRunner: finished: ${pulledOutput?.output?.parameterizedName
?: methodName}($className)")
}
.blockingSubscribe {
bufferedWriter.appendln(it)
Expand All @@ -251,7 +254,7 @@ class KontrastPlugin : Plugin<Project> {

bufferedWriter.close()

if(linesWritten == 0) {
if (linesWritten == 0) {
logcatFile.delete()
}

Expand All @@ -263,20 +266,23 @@ class KontrastPlugin : Plugin<Project> {

private fun createKeyCaptureTask(project: Project, variant: ApplicationVariant, renderTask: RenderOnDeviceTask, targetDevice: AdbDevice): CaptureTestKeyTask {
return project.createTask(type = CaptureTestKeyTask::class,
name = "capture${variant.name.capitalize()}TestKeys_${targetDevice.alias ?: targetDevice.id}",
name = "capture${variant.name.capitalize()}TestKeys_${targetDevice.alias
?: targetDevice.id}",
description = "Capture the current render outputs as new test key",
dependsOn = listOf(renderTask)).apply {
pulledOutputs = renderTask.resultSubject.firstOrError()
outputsDir = File(kontrastDsl.testKeyRoot, "${variant.name}${File.separator}${targetDevice.alias ?: targetDevice.id}")
outputsDir = File(kontrastDsl.testKeyRoot, "${variant.name}${File.separator}${targetDevice.alias
?: targetDevice.id}")
outputs.upToDateWhen { false }
}
}

private fun createRenderTask(project: Project, variant: ApplicationVariant, targetDevice: AdbDevice, mainInstall: InstallApkTask, testInstall: InstallApkTask, artSettlingTask: ArtSettlingTask?): RenderOnDeviceTask {
private fun createRenderTask(project: Project, variant: ApplicationVariant, targetDevice: AdbDevice, mainInstall: InstallApkTask, testInstall: InstallApkTask): RenderOnDeviceTask {
return project.createTask(type = RenderOnDeviceTask::class,
name = "render${variant.name.capitalize()}KontrastViews_${targetDevice.alias ?: targetDevice.id}",
name = "render${variant.name.capitalize()}KontrastViews_${targetDevice.alias
?: targetDevice.id}",
description = "Run kontrast rendering step",
dependsOn = artSettlingTask?.let { listOf(it) } ?: listOf(mainInstall, testInstall)).apply {
dependsOn = listOf(mainInstall, testInstall)).apply {
device = targetDevice
testRunner = variant.testRunner
testPackage = "${variant.applicationId}.test"
Expand All @@ -289,19 +295,11 @@ class KontrastPlugin : Plugin<Project> {
}
}

private fun createSettlingTask(project: Project, variant: ApplicationVariant, targetDevice: AdbDevice, mainInstall: InstallApkTask, testInstall: InstallApkTask): ArtSettlingTask {
return project.createTask(type = ArtSettlingTask::class,
name = "settleArt${variant.name.capitalize()}_${targetDevice.alias ?: targetDevice.id}",
description = "Give the emulator time to settle after apk install to allow art to not segfault on instrumentation invocation.",
dependsOn = listOf(mainInstall, testInstall)).apply {
waitingPeriodMilli = kontrastDsl.artSettlingTimeMillis
}
}

private fun createTestInstallTask(project: Project, variant: ApplicationVariant, targetDevice: AdbDevice): InstallApkTask {
val assembleTestTask = project.tasks.findByName("assemble${variant.name.capitalize()}AndroidTest")
val assembleTestTask = project.tasks.findByName("assemble${variant.name.capitalize()}AndroidTest")!!
return project.createTask(type = InstallApkTask::class,
name = "install${variant.name.capitalize()}TestApk_${targetDevice.alias ?: targetDevice.id}",
name = "install${variant.name.capitalize()}TestApk_${targetDevice.alias
?: targetDevice.id}",
description = "Install test apk for variant ${variant.name}",
dependsOn = listOf(assembleTestTask)).apply {
apk = variant.testApk
Expand All @@ -310,9 +308,10 @@ class KontrastPlugin : Plugin<Project> {
}

private fun createMainInstallTask(project: Project, variant: ApplicationVariant, targetDevice: AdbDevice): InstallApkTask {
val assembleTask = project.tasks.findByName("assemble${variant.name.capitalize()}")
val assembleTask = project.tasks.findByName("assemble${variant.name.capitalize()}")!!
return project.createTask(type = InstallApkTask::class,
name = "install${variant.name.capitalize()}Apk_${targetDevice.alias ?: targetDevice.id}",
name = "install${variant.name.capitalize()}Apk_${targetDevice.alias
?: targetDevice.id}",
description = "Install main apk for variant ${variant.name}",
dependsOn = listOf(assembleTask)).apply {
apk = variant.apk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.gradle.api.DefaultTask

abstract class AdbCommandTask: DefaultTask() {
val plugin: KontrastPlugin
get() = project.plugins.findPlugin(KontrastPlugin::class.java)
get() = project.plugins.findPlugin(KontrastPlugin::class.java)!!

val adb: Adb
get() = plugin.adb
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ class KontrastPluginTest {

fun rootGradleFileContents(kontrastVersion: String) = """
buildscript {
ext.kotlin_version = '1.1.60'
ext.android_plugin_version = '3.0.0'
ext.support_lib_version = '26.1.0'
ext.kotlin_version = '1.2.51'
ext.android_plugin_version = '3.1.3'
ext.support_lib_version = '27.1.1'
ext.min_sdk = 16
ext.target_sdk = 26
ext.target_sdk = 27
repositories {
google()
Expand Down

0 comments on commit e3c489f

Please sign in to comment.