Skip to content

Commit 143d490

Browse files
committed
PAINTROID-786 Update Gradle Plugin to 8.9.1
1 parent a71db0d commit 143d490

File tree

17 files changed

+135
-93
lines changed

17 files changed

+135
-93
lines changed

Jenkinsfile

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
#!groovy
22

3+
class DockerParameters {
4+
5+
// 'docker build' would normally copy the whole build-dir to the container, changing the
6+
// docker build directory avoids that overhead
7+
def dir = 'docker'
8+
def args = '--device /dev/kvm:/dev/kvm -v /var/local/container_shared/gradle_cache/$EXECUTOR_NUMBER:/home/user/.gradle -m=6.5G'
9+
def label = 'LimitedEmulator'
10+
def image = 'floriankanduth/paintroid_java17:latest'
11+
12+
}
13+
14+
def dockerParameters = new DockerParameters()
15+
16+
def startEmulator(String android_version, String stageName) {
17+
sh 'adb start-server'
18+
// creates a new avd, and if it already exists it does nothing.
19+
sh "echo no | avdmanager create avd --force --name android${android_version}" + " --package 'system-images;android-${android_version};default;x86_64'"
20+
sh "/home/user/android/sdk/emulator/emulator -no-window -no-boot-anim -noaudio -avd android${android_version} > ${stageName}_emulator.log 2>&1 &"
21+
}
22+
23+
def waitForEmulatorAndPressWakeUpKey() {
24+
sh 'adb devices'
25+
sh 'timeout 5m adb wait-for-device'
26+
sh '''#!/bin/bash
27+
adb devices
28+
timeout 5m adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1;
29+
done'
30+
echo "Emulator started"
31+
'''
32+
sh '''
33+
adb shell settings put global window_animation_scale 0 &
34+
adb shell settings put global transition_animation_scale 0 &
35+
adb shell settings put global animator_duration_scale 0 &
36+
'''
37+
38+
// In case the device went to sleep
39+
sh 'adb shell input keyevent KEYCODE_WAKEUP'
40+
}
41+
342
def reports = 'Paintroid/build/reports'
443

544
// place the cobertura xml relative to the source, so that the source can be found
@@ -23,17 +62,22 @@ def useDebugLabelParameter(defaultLabel) {
2362
}
2463

2564
pipeline {
65+
environment {
66+
ANDROID_VERSION = 33
67+
ADB_INSTALL_TIMEOUT = 60
68+
}
69+
2670
parameters {
2771
string name: 'DEBUG_LABEL', defaultValue: '', description: 'For debugging when entered will be used as label to decide on which slaves the jobs will run.'
2872
booleanParam name: 'BUILD_WITH_CATROID', defaultValue: false, description: 'When checked then the current Paintroid build will be built with the current develop branch of Catroid'
2973
string name: 'CATROID_BRANCH', defaultValue: 'develop', description: 'The branch which to build catroid with, when BUILD_WITH_CATROID is checked.'
3074
}
3175

3276
agent {
33-
docker {
34-
image 'catrobat/catrobat-paintroid:stable'
35-
args '--device /dev/kvm:/dev/kvm -v /var/local/container_shared/gradle_cache/$EXECUTOR_NUMBER:/home/user/.gradle -m=6.5G'
36-
label 'LimitedEmulator'
77+
docker {
78+
image dockerParameters.image
79+
args dockerParameters.args
80+
label dockerParameters.label
3781
alwaysPull true
3882
}
3983
}
@@ -70,14 +114,14 @@ pipeline {
70114
sh 'rm -rf Catroid; mkdir Catroid'
71115
dir('Catroid') {
72116
git branch: params.CATROID_BRANCH, url: 'https://github.com/Catrobat/Catroid.git'
73-
sh "rm -f catroid/src/main/libs/*.aar"
74-
sh "mv -f ../colorpicker/build/outputs/aar/colorpicker-debug.aar catroid/src/main/libs/colorpicker-LOCAL.aar"
75-
sh "mv -f ../Paintroid/build/outputs/aar/Paintroid-debug.aar catroid/src/main/libs/Paintroid-LOCAL.aar"
117+
sh 'rm -f catroid/src/main/libs/*.aar'
118+
sh 'mv -f ../colorpicker/build/outputs/aar/colorpicker-debug.aar catroid/src/main/libs/colorpicker-LOCAL.aar'
119+
sh 'mv -f ../Paintroid/build/outputs/aar/Paintroid-debug.aar catroid/src/main/libs/Paintroid-LOCAL.aar'
76120
}
77121
renameApks("${env.BRANCH_NAME}-${env.BUILD_NUMBER}")
78122
dir('Catroid') {
79-
archiveArtifacts "catroid/src/main/libs/*.aar"
80-
sh "./gradlew assembleCatroidDebug"
123+
archiveArtifacts 'catroid/src/main/libs/*.aar'
124+
sh './gradlew assembleCatroidDebug'
81125
archiveArtifacts 'catroid/build/outputs/apk/catroid/debug/catroid-catroid-debug.apk'
82126
}
83127
}
@@ -114,9 +158,11 @@ pipeline {
114158

115159
stage('Device Tests') {
116160
steps {
117-
sh "echo no | avdmanager create avd --force --name android28 --package 'system-images;android-28;default;x86_64'"
118-
sh "/home/user/android/sdk/emulator/emulator -no-window -no-boot-anim -noaudio -avd android28 > /dev/null 2>&1 &"
119-
sh './gradlew -PenableCoverage -Pjenkins -Pemulator=android28 -Pci createDebugCoverageReport -i'
161+
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
162+
startEmulator(ANDROID_VERSION, 'device_tests')
163+
waitForEmulatorAndPressWakeUpKey()
164+
sh "./gradlew disableAnimations -PenableCoverage -Pjenkins -Pemulator=android${android_version} -Pci createDebugCoverageReport -i"
165+
}
120166
}
121167
post {
122168
always {
@@ -145,4 +191,4 @@ pipeline {
145191
notifyChat()
146192
}
147193
}
148-
}
194+
}

Paintroid/build.gradle

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
apply plugin: 'com.android.library'
21-
apply plugin: 'com.hiya.jacoco-android'
21+
apply plugin: "com.mxalbert.gradle.jacoco-android"
2222
apply plugin: 'com.getkeepsafe.dexcount'
2323
apply plugin: 'kotlin-android'
2424
apply plugin: 'org.catrobat.gradle.androidemulators'
@@ -51,14 +51,14 @@ emulators {
5151
}
5252

5353
jacoco {
54-
toolVersion = "0.8.7"
54+
toolVersion = "0.8.10"
5555
}
5656

5757
jacocoAndroidUnitTestReport {
58-
csv.enabled false
59-
html.enabled true
60-
xml.enabled true
61-
destination project.getBuildDir().getPath() + "/reports/jacoco/jacocoTestDebugUnitTestReport"
58+
csv.required = false
59+
html.required = true
60+
xml.required = true
61+
destination = project.getBuildDir().getPath() + "/reports/jacoco/jacocoTestDebugUnitTestReport"
6262
}
6363

6464
android {
@@ -68,8 +68,6 @@ android {
6868
minSdkVersion rootProject.ext.androidMinSdkVersion
6969
targetSdkVersion rootProject.ext.androidTargetSdkVersion
7070
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
71-
versionCode rootProject.ext.androidVersionCode
72-
versionName rootProject.ext.androidVersionName
7371
}
7472

7573
compileOptions {
@@ -85,36 +83,39 @@ android {
8583
signedRelease {
8684
}
8785
debug {
88-
testCoverageEnabled = project.hasProperty('enableCoverage')
86+
enableUnitTestCoverage = 'project.hasProperty(\'enableCoverage\')'
87+
enableAndroidTestCoverage = 'project.hasProperty(\'enableCoverage\')'
8988
// Multidex is required as espresso and mockito/bytebuddy are adding more functions
9089
// than should be allowed by law.
9190
// See https://github.com/mockito/mockito/issues/1112
9291
multiDexEnabled true
9392
}
9493
}
9594

96-
lintOptions {
97-
// specific ignores should be defined via lint.xml file
98-
lintConfig file('config/lint.xml')
99-
ignore 'ClickableViewAccessibility', 'StaticFieldLeak', 'GradleDependency', 'OldTargetApi', 'LintBaseline'
100-
textReport true
101-
xmlReport true
102-
htmlReport true
103-
xmlOutput file("build/reports/lint-report.xml")
104-
htmlOutput file("build/reports/lint-report.html")
105-
}
106-
10795
testOptions {
10896
unitTests.returnDefaultValues = true
10997
animationsDisabled = true
11098
}
111-
11299
packagingOptions {
113100
resources {
114101
excludes += ['META-INF/AL2.0', 'META-INF/LGPL2.1', "**/attach_hotspot_windows.dll"]
115102
merges += ['META-INF/licenses/ASM']
116103
}
117104
}
105+
106+
namespace 'org.catrobat.paintroid'
107+
lint {
108+
htmlOutput file('build/reports/lint-report.html')
109+
htmlReport true
110+
ignore 'ClickableViewAccessibility', 'StaticFieldLeak', 'GradleDependency', 'OldTargetApi', 'LintBaseline'
111+
lintConfig file('config/lint.xml')
112+
textReport true
113+
xmlOutput file('build/reports/lint-report.xml')
114+
xmlReport true
115+
}
116+
buildFeatures {
117+
buildConfig true
118+
}
118119
}
119120

120121
dependencies {
@@ -137,16 +138,15 @@ dependencies {
137138
implementation 'com.jraska:falcon:2.2.0'
138139

139140
testImplementation 'junit:junit:4.12'
140-
testImplementation 'org.mockito:mockito-core:2.18.3'
141+
testImplementation 'org.mockito:mockito-core:3.6.28'
141142
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
142143

143144
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.3'
144145
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
145146
androidTestImplementation 'androidx.test:rules:1.1.1'
146-
androidTestImplementation 'org.mockito:mockito-android:3.6.28'
147+
androidTestImplementation 'org.mockito:mockito-android:5.15.2'
147148
androidTestImplementation 'tools.fastlane:screengrab:2.1.0'
148149
androidTestImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
149-
150150
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
151151
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
152152
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'

Paintroid/gradle/code_quality_tasks.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies {
3434
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.20.0"
3535
}
3636

37-
task checkstyle(type: Checkstyle) {
37+
tasks.register('checkstyle', Checkstyle) {
3838
configFile file('config/checkstyle.xml')
3939
source '.'
4040
include '**/*.java', '**/*.kt', '**/*.xml', '**/*.gradle'
@@ -47,12 +47,12 @@ task checkstyle(type: Checkstyle) {
4747
ignoreFailures false
4848

4949
reports {
50-
xml.enabled = true
50+
xml.required = true
5151
xml.destination file("build/reports/checkstyle.xml")
5252
}
5353
}
5454

55-
task pmd(type: Pmd) {
55+
tasks.register('pmd', Pmd) {
5656
ruleSetFiles = files('config/pmd.xml')
5757
ruleSets = []
5858

@@ -63,8 +63,8 @@ task pmd(type: Pmd) {
6363
ignoreFailures false
6464

6565
reports {
66-
xml.enabled = true
67-
html.enabled = true
66+
xml.required = true
67+
html.required = true
6868
xml.destination file("build/reports/pmd.xml")
6969
}
7070
}

Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/api/CorrectStandbyBucketBehaviourTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import android.app.Activity
44
import android.app.usage.UsageStatsManager
55
import android.content.Context
66
import android.os.Build
7-
import androidx.annotation.RequiresApi
87
import androidx.test.ext.junit.rules.ActivityScenarioRule
98
import androidx.test.ext.junit.runners.AndroidJUnit4
9+
import androidx.test.filters.SdkSuppress
1010
import org.catrobat.paintroid.MainActivity
1111
import org.junit.Assert.assertEquals
1212
import org.junit.Before
1313
import org.junit.Rule
1414
import org.junit.Test
1515
import org.junit.runner.RunWith
1616

17-
@RequiresApi(api = Build.VERSION_CODES.P)
17+
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
1818
@RunWith(AndroidJUnit4::class)
1919
class CorrectStandbyBucketBehaviourTests {
2020

Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/dialog/IndeterminateProgressDialogIntegrationTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import android.content.pm.ActivityInfo
2222
import android.content.res.Resources
2323
import android.graphics.PointF
2424
import android.os.Build
25-
import androidx.annotation.RequiresApi
2625
import androidx.fragment.app.DialogFragment
2726
import androidx.test.espresso.Espresso
2827
import androidx.test.espresso.assertion.ViewAssertions
2928
import androidx.test.espresso.matcher.ViewMatchers
3029
import androidx.test.espresso.matcher.ViewMatchers.withId
3130
import androidx.test.ext.junit.runners.AndroidJUnit4
31+
import androidx.test.filters.SdkSuppress
3232
import androidx.test.rule.ActivityTestRule
3333
import org.catrobat.paintroid.MainActivity
3434
import org.catrobat.paintroid.R
@@ -61,7 +61,7 @@ class IndeterminateProgressDialogIntegrationTest {
6161
dialog.dismiss()
6262
}
6363

64-
@RequiresApi(Build.VERSION_CODES.N)
64+
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
6565
@Test
6666
fun testDialogIsShown() {
6767
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
@@ -70,7 +70,7 @@ class IndeterminateProgressDialogIntegrationTest {
7070
}
7171
}
7272

73-
@RequiresApi(Build.VERSION_CODES.N)
73+
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
7474
@Test
7575
fun testDialogIsNotCancelableOnBack() {
7676
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
@@ -80,7 +80,7 @@ class IndeterminateProgressDialogIntegrationTest {
8080
}
8181
}
8282

83-
@RequiresApi(Build.VERSION_CODES.N)
83+
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
8484
@Test
8585
fun testDialogIsNotCancelable() {
8686
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
@@ -92,7 +92,7 @@ class IndeterminateProgressDialogIntegrationTest {
9292
}
9393
}
9494

95-
@RequiresApi(Build.VERSION_CODES.N)
95+
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
9696
@Test
9797
fun testDialogIsRotateAble() {
9898
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/tools/BrushToolIntegrationTest.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ package org.catrobat.paintroid.test.espresso.tools
2020
*/
2121

2222
import android.graphics.Color
23-
import android.os.Build
24-
import androidx.annotation.RequiresApi
2523
import androidx.test.espresso.Espresso
2624
import androidx.test.espresso.action.ViewActions
2725
import androidx.test.espresso.matcher.ViewMatchers.withId
@@ -48,7 +46,6 @@ import org.junit.Rule
4846
import org.junit.Test
4947
import org.junit.runner.RunWith
5048

51-
@RequiresApi(api = Build.VERSION_CODES.P)
5249
@RunWith(AndroidJUnit4::class)
5350
class BrushToolIntegrationTest {
5451

Paintroid/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
-->
2020
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2121
xmlns:tools="http://schemas.android.com/tools"
22-
package="org.catrobat.paintroid"
2322
android:installLocation="auto">
2423

2524
<uses-permission android:name="android.permission.INTERNET"/>

Paintroid/src/main/java/org/catrobat/paintroid/model/LayerModel.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,14 @@ open class LayerModel : LayerContracts.Model {
6565

6666
@Synchronized
6767
override fun getBitmapOfAllLayers(): Bitmap? {
68-
synchronized(this) {
69-
if (layers.isEmpty()) {
70-
return null
71-
}
72-
val referenceBitmap = layers[0].bitmap
73-
val bitmap = Bitmap.createBitmap(referenceBitmap.width, referenceBitmap.height, Bitmap.Config.ARGB_8888)
74-
val canvas = bitmap?.let { Canvas(it) }
75-
76-
drawLayersOntoCanvas(canvas)
77-
78-
return bitmap
68+
if (layers.isEmpty()) {
69+
return null
7970
}
71+
val referenceBitmap = layers[0].bitmap
72+
val bitmap = Bitmap.createBitmap(referenceBitmap.width, referenceBitmap.height, Bitmap.Config.ARGB_8888)
73+
val canvas = bitmap?.let { Canvas(it) }
74+
drawLayersOntoCanvas(canvas)
75+
return bitmap
8076
}
8177

8278
override fun getBitmapListOfAllLayers(): List<Bitmap?> = layers.map { it.bitmap }

0 commit comments

Comments
 (0)