diff --git a/.github/workflows/assembleFlavors.yml b/.github/workflows/assembleFlavors.yml index 587b27b0d698..057d02649ec0 100644 --- a/.github/workflows/assembleFlavors.yml +++ b/.github/workflows/assembleFlavors.yml @@ -47,5 +47,4 @@ jobs: echo "kotlin.daemon.jvmargs=-Xmx3g -XX:+UseParallelGC -XX:MaxMetaspaceSize=512m" echo "org.gradle.workers.max=2" } >> gradle.properties - ./gradlew ${{ matrix.tasks }} - + ./gradlew ${{ matrix.tasks }} -Pminify diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 7386a4ad003d..48ae0657ca27 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -40,7 +40,7 @@ jobs: uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 - name: Run unit tests with coverage - run: ./gradlew jacocoTestGplayDebugUnitTest + run: ./gradlew jacocoTestGplayDebugUnitTest -Pminify - name: Upload failing results if: ${{ failure() }} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9db2148e375c..0080cc34ae9b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -20,6 +20,8 @@ val shotTest = System.getenv("SHOT_TEST") == "true" val ciBuild = System.getenv("CI") == "true" val perfAnalysis = project.hasProperty("perfAnalysis") +val minify = project.hasProperty("minify") // shall be off by default + plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.compose) @@ -141,11 +143,20 @@ android { flavorDimensions += "default" buildTypes { + fun com.android.build.api.dsl.BuildType.commonMinifyConfig() { + isMinifyEnabled = minify + isShrinkResources = minify + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } release { + commonMinifyConfig() buildConfigField("String", "NC_TEST_SERVER_DATA_STRING", "\"\"") } - debug { + commonMinifyConfig() enableUnitTestCoverage = project.hasProperty("coverage") enableAndroidTestCoverage = project.hasProperty("coverage") resConfigs("xxxhdpi") diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 000000000000..3817ac49aca7 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,24 @@ +# Nextcloud - Android Client +# +# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: AGPL-3.0-or-later + +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. + +# Silence missing-class warnings from optional transitive dependencies and Android/JDK API gaps. +-dontwarn com.gemalto.jp2.JP2Decoder +-dontwarn com.gemalto.jp2.JP2Encoder +-dontwarn java.time.zone.ZoneRulesProvider +-dontwarn org.joda.convert.ToString + +# Commons HttpClient is still used at runtime, so keep these packages from being stripped or renamed. +-keep class org.apache.commons.httpclient.* { *; } +-keep class org.apache.commons.httpclient.auth.** { *; } + +# Some libraries load .properties resources relative to their package. +# Keeping the package names preserves Class.getResourceAsStream(...) lookups after shrinking. +-keeppackagenames org.apache.jackrabbit.webdav +-keeppackagenames net.fortuna.ical4j +-keep class org.apache.commons.httpclient.cookie.** { *; } diff --git a/scripts/runAllScreenshotCombinations b/scripts/runAllScreenshotCombinations index 6e208d20eed0..a0d7caf99950 100755 --- a/scripts/runAllScreenshotCombinations +++ b/scripts/runAllScreenshotCombinations @@ -30,6 +30,7 @@ do if [[ $1 = "noCI" ]]; then ./gradlew --console plain genericDebugExecuteScreenshotTests \ $record \ + -Pminify \ -Pscreenshot=true \ -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \ -Pandroid.testInstrumentationRunnerArguments.COLOR="$color" \ @@ -43,6 +44,7 @@ do else ./gradlew --console plain genericDebugExecuteScreenshotTests \ $record \ + -Pminify \ -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \ -Pandroid.testInstrumentationRunnerArguments.COLOR="$color" \ -Pandroid.testInstrumentationRunnerArguments.DARKMODE="$darkMode" /dev/null \ diff --git a/scripts/runCombinedTest.sh b/scripts/runCombinedTest.sh index 86ecf0cc6763..29c12989b0a6 100755 --- a/scripts/runCombinedTest.sh +++ b/scripts/runCombinedTest.sh @@ -24,12 +24,13 @@ scripts/deleteOldComments.sh "$BRANCH" "IT" "$DRONE_PULL_REQUEST" scripts/wait_for_emulator.sh || exit 1 -./gradlew installGplayDebugAndroidTest +./gradlew installGplayDebugAndroidTest -Pminify gradle_arguments=( -Pcoverage -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest -Pandroid.testInstrumentationRunnerArguments.filter=com.nextcloud.test.FlakyTestFilter,com.nextcloud.test.ServerVersionFilter + -Pminify ) if [[ "$BRANCH" =~ ^stable([0-9]+)$ ]]; then