Skip to content

Commit c4acccc

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

File tree

19 files changed

+180
-94
lines changed

19 files changed

+180
-94
lines changed

Jenkinsfile

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
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+
39+
// In case the device went to sleep
40+
sh 'adb shell input keyevent KEYCODE_WAKEUP'
41+
}
42+
343
def reports = 'Paintroid/build/reports'
444

545
// place the cobertura xml relative to the source, so that the source can be found
@@ -22,18 +62,32 @@ def useDebugLabelParameter(defaultLabel) {
2262
return env.DEBUG_LABEL?.trim() ? env.DEBUG_LABEL : defaultLabel
2363
}
2464

65+
def checkAnimationScale(scaleName) {
66+
def output = sh(script: "adb shell settings get global ${scaleName}", returnStdout: true).trim()
67+
if (output != "0" && output != "0.0") {
68+
error("Animation scale '${scaleName}' is NOT disabled. Current value: ${output}")
69+
} else {
70+
echo("Animation scale '${scaleName}' is disabled (Value: ${output})")
71+
}
72+
}
73+
2574
pipeline {
75+
environment {
76+
ANDROID_VERSION = 33
77+
ADB_INSTALL_TIMEOUT = 60
78+
}
79+
2680
parameters {
2781
string name: 'DEBUG_LABEL', defaultValue: '', description: 'For debugging when entered will be used as label to decide on which slaves the jobs will run.'
2882
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'
2983
string name: 'CATROID_BRANCH', defaultValue: 'develop', description: 'The branch which to build catroid with, when BUILD_WITH_CATROID is checked.'
3084
}
3185

3286
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'
87+
docker {
88+
image dockerParameters.image
89+
args dockerParameters.args
90+
label dockerParameters.label
3791
alwaysPull true
3892
}
3993
}
@@ -70,14 +124,14 @@ pipeline {
70124
sh 'rm -rf Catroid; mkdir Catroid'
71125
dir('Catroid') {
72126
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"
127+
sh 'rm -f catroid/src/main/libs/*.aar'
128+
sh 'mv -f ../colorpicker/build/outputs/aar/colorpicker-debug.aar catroid/src/main/libs/colorpicker-LOCAL.aar'
129+
sh 'mv -f ../Paintroid/build/outputs/aar/Paintroid-debug.aar catroid/src/main/libs/Paintroid-LOCAL.aar'
76130
}
77131
renameApks("${env.BRANCH_NAME}-${env.BUILD_NUMBER}")
78132
dir('Catroid') {
79-
archiveArtifacts "catroid/src/main/libs/*.aar"
80-
sh "./gradlew assembleCatroidDebug"
133+
archiveArtifacts 'catroid/src/main/libs/*.aar'
134+
sh './gradlew assembleCatroidDebug'
81135
archiveArtifacts 'catroid/build/outputs/apk/catroid/debug/catroid-catroid-debug.apk'
82136
}
83137
}
@@ -114,9 +168,16 @@ pipeline {
114168

115169
stage('Device Tests') {
116170
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'
171+
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
172+
startEmulator(ANDROID_VERSION, 'device_tests')
173+
waitForEmulatorAndPressWakeUpKey()
174+
script {
175+
checkAnimationScale("window_animation_scale")
176+
checkAnimationScale("transition_animation_scale")
177+
checkAnimationScale("animator_duration_scale")
178+
}
179+
sh "./gradlew disableAnimations -PenableCoverage -Pjenkins -Pemulator=android${android_version} -Pci createDebugCoverageReport -i"
180+
}
120181
}
121182
post {
122183
always {
@@ -145,4 +206,4 @@ pipeline {
145206
notifyChat()
146207
}
147208
}
148-
}
209+
}

Paintroid/build.gradle

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
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'
2525
apply plugin: 'maven-publish'
2626

2727
apply from: 'gradle/adb_tasks.gradle'
2828
apply from: 'gradle/code_quality_tasks.gradle'
29+
apply from: 'gradle/emulator.gradle'
2930

3031
emulators {
3132
install project.hasProperty('installSdk')
@@ -51,14 +52,14 @@ emulators {
5152
}
5253

5354
jacoco {
54-
toolVersion = "0.8.7"
55+
toolVersion = "0.8.10"
5556
}
5657

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

6465
android {
@@ -68,8 +69,6 @@ android {
6869
minSdkVersion rootProject.ext.androidMinSdkVersion
6970
targetSdkVersion rootProject.ext.androidTargetSdkVersion
7071
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
71-
versionCode rootProject.ext.androidVersionCode
72-
versionName rootProject.ext.androidVersionName
7372
}
7473

7574
compileOptions {
@@ -85,36 +84,39 @@ android {
8584
signedRelease {
8685
}
8786
debug {
88-
testCoverageEnabled = project.hasProperty('enableCoverage')
87+
enableUnitTestCoverage = 'project.hasProperty(\'enableCoverage\')'
88+
enableAndroidTestCoverage = 'project.hasProperty(\'enableCoverage\')'
8989
// Multidex is required as espresso and mockito/bytebuddy are adding more functions
9090
// than should be allowed by law.
9191
// See https://github.com/mockito/mockito/issues/1112
9292
multiDexEnabled true
9393
}
9494
}
9595

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-
10796
testOptions {
10897
unitTests.returnDefaultValues = true
10998
animationsDisabled = true
11099
}
111-
112100
packagingOptions {
113101
resources {
114102
excludes += ['META-INF/AL2.0', 'META-INF/LGPL2.1', "**/attach_hotspot_windows.dll"]
115103
merges += ['META-INF/licenses/ASM']
116104
}
117105
}
106+
107+
namespace 'org.catrobat.paintroid'
108+
lint {
109+
htmlOutput file('build/reports/lint-report.html')
110+
htmlReport true
111+
ignore 'ClickableViewAccessibility', 'StaticFieldLeak', 'GradleDependency', 'OldTargetApi', 'LintBaseline'
112+
lintConfig file('config/lint.xml')
113+
textReport true
114+
xmlOutput file('build/reports/lint-report.xml')
115+
xmlReport true
116+
}
117+
buildFeatures {
118+
buildConfig true
119+
}
118120
}
119121

120122
dependencies {
@@ -137,16 +139,15 @@ dependencies {
137139
implementation 'com.jraska:falcon:2.2.0'
138140

139141
testImplementation 'junit:junit:4.12'
140-
testImplementation 'org.mockito:mockito-core:2.18.3'
142+
testImplementation 'org.mockito:mockito-core:3.6.28'
141143
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
142144

143145
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.3'
144146
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
145147
androidTestImplementation 'androidx.test:rules:1.1.1'
146-
androidTestImplementation 'org.mockito:mockito-android:3.6.28'
148+
androidTestImplementation 'org.mockito:mockito-android:5.15.2'
147149
androidTestImplementation 'tools.fastlane:screengrab:2.1.0'
148150
androidTestImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
149-
150151
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
151152
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
152153
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/gradle/emulator.gradle

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Paintroid: An image manipulation application for Android.
3+
* Copyright (C) 2010-2025 The Catrobat Team
4+
* (<http://developer.catrobat.org/credits>)
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
tasks.register('disableAnimations') {
21+
it.group 'android'
22+
doLast {
23+
'adb shell settings put global window_animation_scale 0'.execute()
24+
'adb shell settings put global transition_animation_scale 0'.execute()
25+
'adb shell settings put global animator_duration_scale 0'.execute()
26+
}
27+
}

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

0 commit comments

Comments
 (0)