diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index 50e1e06ae0..91766d9029 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -31,7 +31,7 @@ jobs: java-version: 17 - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@v2.4.2 - name: Accept Android licenses run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses || true @@ -39,27 +39,17 @@ jobs: - name: Check spotless run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache - - name: Check lint - run: ./gradlew lintfossDebug - - name: Build all build type and flavor permutations run: ./gradlew assemble - - name: Run local tests - run: ./gradlew testfossDebug testMarketDebug - - name: Upload build outputs (APKs) uses: actions/upload-artifact@v3 with: name: APKs path: '**/build/outputs/apk/**/*.apk' - - name: Upload lint reports (HTML) - if: always() - uses: actions/upload-artifact@v3 - with: - name: lint-reports - path: '**/build/reports/lint-results-*.html' + - name: Run local tests + run: ./gradlew testfossDebug testMarketDebug - name: Upload test results (XML) if: always() @@ -67,6 +57,15 @@ jobs: with: name: test-results path: '**/build/test-results/test*UnitTest/**.xml' + - name: Check lint + run: ./gradlew :app-compose:lintMarketRelease :lint:lint + + - name: Upload lint reports (HTML) + if: always() + uses: actions/upload-artifact@v3 + with: + name: lint-reports + path: '**/build/reports/lint-results-*.html' androidTest: needs: build @@ -90,7 +89,7 @@ jobs: java-version: 17 - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@v2.4.2 - name: Run instrumentation tests uses: reactivecircus/android-emulator-runner@v2 @@ -128,7 +127,7 @@ jobs: java-version: 17 - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@v2.4.2 - name: Setup Android SDK uses: android-actions/setup-android@v2 diff --git a/app-compose/build.gradle.kts b/app-compose/build.gradle.kts index d718a4278d..63a1f74911 100644 --- a/app-compose/build.gradle.kts +++ b/app-compose/build.gradle.kts @@ -137,12 +137,3 @@ dependencies { implementation(libs.libsu.core) implementation(libs.timber) } - -// androidx.test is forcing JUnit, 4.12. This forces it to use 4.13 -configurations.configureEach { - resolutionStrategy { - force(libs.junit4) - // Temporary workaround for https://issuetracker.google.com/174733673 - force("org.objenesis:objenesis:2.6") - } -} diff --git a/app-compose/proguard-rules.pro b/app-compose/proguard-rules.pro index b6b87277ac..61d6c93e7c 100644 --- a/app-compose/proguard-rules.pro +++ b/app-compose/proguard-rules.pro @@ -1,34 +1,7 @@ -# Keep `Companion` object fields of serializable classes. -# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects. --if @kotlinx.serialization.Serializable class ** --keepclassmembers class <1> { - static <1>$Companion Companion; -} - -# Keep `serializer()` on companion objects (both default and named) of serializable classes. --if @kotlinx.serialization.Serializable class ** { - static **$* *; -} --keepclassmembers class <2>$<3> { - kotlinx.serialization.KSerializer serializer(...); -} - -# Keep `INSTANCE.serializer()` of serializable objects. --if @kotlinx.serialization.Serializable class ** { - public static ** INSTANCE; -} --keepclassmembers class <1> { - public static <1> INSTANCE; - kotlinx.serialization.KSerializer serializer(...); -} - # Don't obsufcate classes under com.merxury package # In order to make the error readable, we need to keep the class name -keep class com.merxury.** { *; } -# @Serializable and @Polymorphic are used at runtime for polymorphic serialization. --keepattributes RuntimeVisibleAnnotations,AnnotationDefault - # Will be fixed in okhttp5 https://github.com/square/okhttp/issues/6258 -dontwarn org.bouncycastle.jsse.BCSSLParameters -dontwarn org.bouncycastle.jsse.BCSSLSocket diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a91f73c304..a8483a4f15 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -160,12 +160,3 @@ dependencies { implementation(libs.shizuku.api) implementation(libs.shizuku.provider) } - -// androidx.test is forcing JUnit, 4.12. This forces it to use 4.13 -configurations.configureEach { - resolutionStrategy { - force(libs.junit4) - // Temporary workaround for https://issuetracker.google.com/174733673 - force("org.objenesis:objenesis:2.6") - } -} diff --git a/benchmarks/src/main/java/com/merxury/blocker/baselineprofile/BaselineProfileGenerator.kt b/benchmarks/src/main/java/com/merxury/blocker/baselineprofile/BaselineProfileGenerator.kt index bca117bbf9..f6023dcfd4 100644 --- a/benchmarks/src/main/java/com/merxury/blocker/baselineprofile/BaselineProfileGenerator.kt +++ b/benchmarks/src/main/java/com/merxury/blocker/baselineprofile/BaselineProfileGenerator.kt @@ -16,7 +16,6 @@ package com.merxury.blocker.baselineprofile -import androidx.benchmark.macro.ExperimentalBaselineProfilesApi import androidx.benchmark.macro.junit4.BaselineProfileRule import com.merxury.blocker.PACKAGE_NAME import com.merxury.blocker.applist.appListScrollDownUp @@ -30,13 +29,12 @@ import org.junit.Test /** * Generates a baseline profile which can be copied to `app/src/main/baseline-prof.txt`. */ -@ExperimentalBaselineProfilesApi class BaselineProfileGenerator { @get:Rule val baselineProfileRule = BaselineProfileRule() @Test fun generate() = - baselineProfileRule.collectBaselineProfile(PACKAGE_NAME) { + baselineProfileRule.collect(PACKAGE_NAME) { // This block defines the app's critical user journey. Here we are interested in // optimizing for app startup. But you can also navigate and scroll // through your most important UI. diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index dc00e533ad..5cfb580d1b 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -91,6 +91,10 @@ gradlePlugin { id = "blocker.android.application.flavors" implementationClass = "AndroidApplicationFlavorsConventionPlugin" } + register("androidLint") { + id = "blocker.android.lint" + implementationClass = "AndroidLintConventionPlugin" + } register("jvmLibrary") { id = "nowinandroid.jvm.library" implementationClass = "JvmLibraryConventionPlugin" diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt index 2030860e9d..c4b2e9ea2f 100644 --- a/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt @@ -32,6 +32,7 @@ class AndroidApplicationConventionPlugin : Plugin { with(pluginManager) { apply("com.android.application") apply("org.jetbrains.kotlin.android") + apply("blocker.android.lint") } extensions.configure { configureKotlinAndroid(this) diff --git a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt index 6b82533193..a5e7dc54c8 100644 --- a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt @@ -21,7 +21,6 @@ import com.merxury.blocker.configureGradleManagedDevices import com.merxury.blocker.configureKotlinAndroid import com.merxury.blocker.configurePrintApksTask import com.merxury.blocker.disableUnnecessaryAndroidTests -import com.merxury.blocker.libs import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.JavaPluginExtension @@ -36,6 +35,7 @@ class AndroidLibraryConventionPlugin : Plugin { with(pluginManager) { apply("com.android.library") apply("org.jetbrains.kotlin.android") + apply("blocker.android.lint") } extensions.configure { configureKotlinAndroid(this) @@ -52,13 +52,6 @@ class AndroidLibraryConventionPlugin : Plugin { languageVersion.set(JavaLanguageVersion.of(17)) } } - configurations.configureEach { - resolutionStrategy { - force(libs.findLibrary("junit4").get()) - // Temporary workaround for https://issuetracker.google.com/174733673 - force("org.objenesis:objenesis:2.6") - } - } dependencies { add("androidTestImplementation", kotlin("test")) add("testImplementation", kotlin("test")) diff --git a/build-logic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt new file mode 100644 index 0000000000..0b6bd64479 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.android.build.api.dsl.ApplicationExtension +import com.android.build.api.dsl.LibraryExtension +import com.android.build.api.dsl.Lint +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure + +class AndroidLintConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + when { + pluginManager.hasPlugin("com.android.application") -> + configure { lint(Lint::configure) } + + pluginManager.hasPlugin("com.android.library") -> + configure { lint(Lint::configure) } + + else -> { + pluginManager.apply("com.android.lint") + configure(Lint::configure) + } + } + } + } +} + +private fun Lint.configure() { + xmlReport = true + checkDependencies = true +} \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/JvmLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/JvmLibraryConventionPlugin.kt index bbe1c43a2e..c692188a95 100644 --- a/build-logic/convention/src/main/kotlin/JvmLibraryConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/JvmLibraryConventionPlugin.kt @@ -24,6 +24,7 @@ class JvmLibraryConventionPlugin : Plugin { with(target) { with(pluginManager) { apply("org.jetbrains.kotlin.jvm") + apply("blocker.android.lint") } configureKotlinJvm() } diff --git a/core/component-controller/proguard-rules.pro b/core/component-controller/proguard-rules.pro deleted file mode 100644 index 2f9dc5a47e..0000000000 --- a/core/component-controller/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle.kts. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index ae39c0e532..4610aea21f 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -23,9 +23,6 @@ android { defaultConfig { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - lint { - checkDependencies = true - } namespace = "com.merxury.blocker.core.designsystem" } diff --git a/core/ifw-api/proguard-rules.pro b/core/ifw-api/proguard-rules.pro index 9100470264..490a86338c 100644 --- a/core/ifw-api/proguard-rules.pro +++ b/core/ifw-api/proguard-rules.pro @@ -1,17 +1,3 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle.kts. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable diff --git a/core/provider/proguard-rules.pro b/core/provider/proguard-rules.pro deleted file mode 100644 index 481bb43481..0000000000 --- a/core/provider/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/core/rule/proguard-rules.pro b/core/rule/proguard-rules.pro deleted file mode 100644 index 481bb43481..0000000000 --- a/core/rule/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index e70219c53f..30118c5f37 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ org.gradle.configureondemand=false # Enable caching between builds. org.gradle.caching=true # Enable configuration caching between builds. -org.gradle.unsafe.configuration-cache=true +org.gradle.configuration-cache=true # AndroidX package structure to make it clearer which packages are bundled with the # Android operating system, and which are packaged with your app"s APK # https://developer.android.com/topic/libraries/support-library/androidx-rn @@ -28,9 +28,6 @@ kotlin.code.style=official android.nonTransitiveRClass=true # Disable build features that are enabled by default, # https://developer.android.com/studio/releases/gradle-plugin#buildFeatures -android.defaults.buildfeatures.buildconfig=false -android.defaults.buildfeatures.aidl=false -android.defaults.buildfeatures.renderscript=false android.defaults.buildfeatures.resvalues=false android.defaults.buildfeatures.shaders=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ae9753970b..a2e64a03ff 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ androidxDataStore = "1.0.0" androidxEspresso = "3.5.1" androidxHiltNavigationCompose = "1.0.0" androidxLifecycle = "2.6.1" -androidxMacroBenchmark = "1.1.1" +androidxMacroBenchmark = "1.2.0-alpha16" androidxComposeMaterial = "1.4.3" androidxNavigation = "2.6.0" androidxMetrics = "1.0.0-alpha04" diff --git a/lint/build.gradle.kts b/lint/build.gradle.kts index b665ba8a77..d013456084 100644 --- a/lint/build.gradle.kts +++ b/lint/build.gradle.kts @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { `java-library` kotlin("jvm") - id("com.android.lint") + id("blocker.android.lint") } java {