Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for JDK 17 #292

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove all the references to previous JDK configs we don't need? I'd like to use the minimum version possible. So if we can use JDK 11, please keep JDK 11 and remove the versions we don't need 😃

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, sounds good 👍

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Check code formatting
run: ./gradlew clean checkScalaFmtAll ktlintCheck
- name: Shot unit tests
Expand Down Expand Up @@ -85,6 +89,10 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
- name: Set up JDK 11
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean 17 here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, good catch

uses: actions/setup-java@v1
with:
java-version: 17
- name: Disable artifacts signing
run: echo "RELEASE_SIGNING_ENABLED=false" >> gradle.properties
- name: Build and install Shot
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ buildscript {
google()
}

ext.kotlin_version = "1.4.32"
ext.kotlin_version = "1.6.10"

dependencies {
classpath "gradle.plugin.com.github.maiflai:gradle-scalatest:0.31"
classpath "gradle.plugin.cz.alenkacz:gradle-scalafmt:1.16.2"
classpath "com.android.tools.build:gradle:4.1.3"
classpath "com.android.tools.build:gradle:7.1.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.0.0"
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.15.1'
Expand Down
4 changes: 3 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ repositories {
dependencies {
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 'com.sksamuel.scrimage:scrimage-core:4.0.31'
implementation 'com.sksamuel.scrimage:scrimage-scala_2.12:4.0.31'
implementation 'io.github.bitstorm:tinyzip-core:1.0.0'
implementation 'org.json4s:json4s-native_2.12:3.6.11'
implementation 'org.json4s:json4s-jackson_2.12:3.6.11'
implementation 'commons-io:commons-io:2.11.0'

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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
package com.karumi.shot.screenshots

import java.io.File

import com.karumi.shot.domain.Screenshot
import com.sksamuel.scrimage.{AwtImage, Color, Image}
import com.sksamuel.scrimage.color.Colors
import com.sksamuel.scrimage.{AwtImage, ImmutableImage}

object ScreenshotComposer {

private val tileSize = 512

private[screenshots] def composeNewScreenshot(screenshot: Screenshot): Image = {
private[screenshots] def composeNewScreenshot(screenshot: Screenshot): ImmutableImage = {
val width = screenshot.screenshotDimension.width
val height = screenshot.screenshotDimension.height
if (screenshot.recordedPartsPaths.size == 1) {
Image.fromFile(new File(screenshot.recordedPartsPaths.head))
ImmutableImage.loader().fromFile(new File(screenshot.recordedPartsPaths.head))
} else {
var composedImage = Image.filled(width, height, Color.Transparent)
var composedImage = ImmutableImage.filled(width, height, Colors.Transparent.toAWT)
var partIndex = 0
for (
x <- 0 until screenshot.tilesDimension.width;
y <- 0 until screenshot.tilesDimension.height
) {
val partFile = new File(screenshot.recordedPartsPaths(partIndex))
val part = Image.fromFile(partFile).awt
val part = ImmutableImage.loader().fromFile(partFile).awt
val xPosition = x * tileSize
val yPosition = y * tileSize
composedImage = composedImage.overlay(new AwtImage(part), xPosition, yPosition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.io.File

import com.karumi.shot.domain._
import com.karumi.shot.domain.model.ScreenshotsSuite
import com.sksamuel.scrimage.Image
import com.sksamuel.scrimage.ImmutableImage

class ScreenshotsComparator {

Expand All @@ -23,7 +23,7 @@ class ScreenshotsComparator {
Some(ScreenshotNotFound(screenshot))
} else {
val oldScreenshot =
Image.fromFile(recordedScreenshotFile)
ImmutableImage.loader().fromFile(recordedScreenshotFile)
val newScreenshot = ScreenshotComposer.composeNewScreenshot(screenshot)
if (!haveSameDimensions(newScreenshot, oldScreenshot)) {
val originalDimension =
Expand All @@ -40,8 +40,8 @@ class ScreenshotsComparator {

private def imagesAreDifferent(
screenshot: Screenshot,
oldScreenshot: Image,
newScreenshot: Image,
oldScreenshot: ImmutableImage,
newScreenshot: ImmutableImage,
tolerance: Double
) = {
if (oldScreenshot == newScreenshot) {
Expand All @@ -67,7 +67,10 @@ class ScreenshotsComparator {
}
}

private def haveSameDimensions(newScreenshot: Image, recordedScreenshot: Image): Boolean =
private def haveSameDimensions(
newScreenshot: ImmutableImage,
recordedScreenshot: ImmutableImage
): Boolean =
newScreenshot.width == recordedScreenshot.width && newScreenshot.height == recordedScreenshot.height

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.karumi.shot.screenshots

import java.io.File

import com.karumi.shot.base64.Base64Encoder
import com.karumi.shot.domain.model.ScreenshotComparisionErrors
import com.karumi.shot.domain.{DifferentScreenshots, ScreenshotsComparisionResult}
import com.sksamuel.scrimage.Image
import com.sksamuel.scrimage.ImmutableImage
import com.sksamuel.scrimage.composite.RedComposite
import com.sksamuel.scrimage.nio.PngWriter

class ScreenshotsDiffGenerator(base64Encoder: Base64Encoder) {

Expand All @@ -32,11 +32,11 @@ class ScreenshotsDiffGenerator(base64Encoder: Base64Encoder) {
val screenshot = error.screenshot
val originalImagePath = screenshot.recordedScreenshotPath
val newImagePath = screenshot.temporalScreenshotPath
val originalImage = Image.fromFile(new File(originalImagePath))
val newImage = Image.fromFile(new File(newImagePath))
val originalImage = ImmutableImage.loader().fromFile(new File(originalImagePath))
val newImage = ImmutableImage.loader().fromFile(new File(newImagePath))
Jawnnypoo marked this conversation as resolved.
Show resolved Hide resolved
val diff = newImage.composite(new RedComposite(1d), originalImage)
val outputFilePath = screenshot.getDiffScreenshotPath(outputFolder)
diff.output(outputFilePath)
diff.output(PngWriter.NoCompression, outputFilePath)
if (generateBase64Diff) {
error.copy(base64Diff = base64Encoder.base64FromFile(outputFilePath))
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
package com.karumi.shot.screenshots

import java.io.File
import com.karumi.shot.domain.{
Config,
DifferentImageDimensions,
DifferentScreenshots,
Dimension,
Screenshot,
ScreenshotNotFound,
ScreenshotsComparisionResult,
ShotFolder
}
import com.karumi.shot.domain.{Dimension, Screenshot, ScreenshotsComparisionResult, ShotFolder}
import com.karumi.shot.domain.model.{FilePath, Folder, ScreenshotsSuite}
import com.sksamuel.scrimage.Image
import com.sksamuel.scrimage.ImmutableImage
import com.sksamuel.scrimage.nio.PngWriter
import org.apache.commons.io.FileUtils

class ScreenshotsSaver {
Expand Down Expand Up @@ -71,7 +63,7 @@ class ScreenshotsSaver {
screenshot: Screenshot
): Dimension = {
val screenshotPath = shotFolder.pulledScreenshotsFolder() + screenshot.name + ".png"
val image = Image.fromFile(new File(screenshotPath))
val image = ImmutableImage.loader().fromFile(new File(screenshotPath))
Dimension(image.width, image.height)
}

Expand All @@ -97,7 +89,7 @@ class ScreenshotsSaver {
outputFile.createNewFile()
}
val image = ScreenshotComposer.composeNewScreenshot(screenshot)
image.output(outputFile)
image.output(PngWriter.NoCompression, outputFile)
}
}

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ POM_SCM_CONNECTION=scm:git@github.com:pedrovgs/shot.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:pedrovgs/shot.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt

POM_DEVELOPER_ID=pedrovgs
POM_DEVELOPER_NAME=Pedro Vicente Gomez Sanchez
android.useAndroidX=true
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-7.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
54 changes: 24 additions & 30 deletions shot-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ apply plugin: "org.jlleitschuh.gradle.ktlint"
apply plugin: "com.vanniktech.maven.publish"

android {
compileSdkVersion 28
compileSdk 32
testOptions.unitTests.includeAndroidResources = true

defaultConfig {
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "com.karumi.shot.DexOpenerJUnitRunner"
Expand Down Expand Up @@ -38,51 +38,45 @@ repositories {
mavenLocal()
google()
maven { url 'https://jitpack.io' }
exclusiveContent {
forRepository { jcenter() }
filter {
includeModule("org.jetbrains.kotlinx", "kotlinx-collections-immutable-jvm")
includeGroup("org.jetbrains.trove4j")
}
}
}

dependencies {
implementation "com.facebook.testing.screenshot:core:0.14.0"
implementation "androidx.test:runner:1.3.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"
implementation "androidx.test:runner:1.4.0"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.test.espresso:espresso-core:3.4.0"
implementation "androidx.compose.ui:ui-test-junit4:1.1.1"
implementation "com.google.code.gson:gson:2.8.8"

// fragment-testing dependency is normally declared for debug (not test) sources,
// as you'd usually run your FragmentScenario tests only in debug variants.
// The inspection checks against including it in release variants and recommends using
// debugImplementation instead. However it doesn't matter here because we're still only using it
// for testing purposes. FragmentScenario API is needed to provide waitForFragment() extension.
//noinspection FragmentGradleConfiguration
implementation "androidx.fragment:fragment-testing:1.3.2"
implementation "androidx.fragment:fragment-testing:1.4.1"

testImplementation "junit:junit:4.13.2"
testImplementation "org.mockito:mockito-core:3.9.0"
testImplementation "org.mockito:mockito-core:4.3.1"
testImplementation "com.nhaarman:mockito-kotlin:1.6.0"
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"
testImplementation "androidx.test.espresso:espresso-core:3.3.0"
testImplementation "androidx.test.espresso:espresso-intents:3.3.0"
testImplementation "androidx.test.espresso:espresso-contrib:3.3.0"
testImplementation "org.robolectric:robolectric:4.7.3"
testImplementation "androidx.test.ext:junit:1.1.3"
testImplementation "androidx.test:runner:1.4.0"
testImplementation "androidx.test:rules:1.4.0"
testImplementation "androidx.test.espresso:espresso-core:3.4.0"
testImplementation "androidx.test.espresso:espresso-intents:3.4.0"
testImplementation "androidx.test.espresso:espresso-contrib:3.4.0"

androidTestImplementation "com.github.tmurakami:dexopener:2.0.5"
androidTestImplementation "org.mockito:mockito-android:2.28.2"
androidTestImplementation "org.mockito:mockito-android:4.3.1"
androidTestImplementation "org.mockito.kotlin:mockito-kotlin:4.3.1"
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
androidTestImplementation "androidx.test:runner:1.3.0"
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0"
androidTestImplementation "androidx.test.espresso:espresso-intents:3.3.0"
androidTestImplementation "androidx.test.espresso:espresso-contrib:3.3.0"
androidTestImplementation "androidx.test:rules:1.3.0"
androidTestImplementation "androidx.test.ext:junit:1.1.2"
androidTestImplementation "androidx.test:runner:1.4.0"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
androidTestImplementation "androidx.test.espresso:espresso-intents:3.4.0"
androidTestImplementation "androidx.test.espresso:espresso-contrib:3.4.0"
androidTestImplementation "androidx.test:rules:1.4.0"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
Expand Down
8 changes: 3 additions & 5 deletions shot-consumer-compose/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
compose_version = '1.0.0-beta03'
compose_version = '1.0.0'
}
ext.kotlin_version = "1.4.31"
ext.kotlin_version = "1.6.10"
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0-alpha12'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.karumi:shot:5.14.0"
}
Expand All @@ -20,7 +19,6 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
}
Expand Down
1 change: 0 additions & 1 deletion shot-consumer-flavors/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ buildscript {
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
jcenter()
google()
}
dependencies {
Expand Down
6 changes: 2 additions & 4 deletions shot-consumer-flavors/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
buildscript {
ext.kotlin_version = '1.4.21'
ext.kotlin_version = '1.6.10'
repositories {
mavenLocal()
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.0-beta01"
classpath "com.android.tools.build:gradle:7.1.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.karumi:shot:5.14.0"
}
Expand All @@ -16,7 +15,6 @@ allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
Expand Down
5 changes: 3 additions & 2 deletions shot-consumer-library-no-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.1.0-alpha06")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21")

classpath("com.android.tools.build:gradle:7.1.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
classpath("com.karumi:shot:5.14.0")

// NOTE: Do not place your application dependencies here; they belong
Expand Down
1 change: 0 additions & 1 deletion shot-consumer-library-no-tests/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dependencyResolutionManagement {
mavenLocal()
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
rootProject.name = "ShotAGPBug"
Expand Down
1 change: 0 additions & 1 deletion shot-consumer/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ buildscript {
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
jcenter()
google()
}
dependencies {
Expand Down
1 change: 0 additions & 1 deletion shot-consumer/app2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ buildscript {
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
jcenter()
google()
}
dependencies {
Expand Down
Loading