Skip to content

Commit

Permalink
Merge pull request #203 from lihenggui/modularization
Browse files Browse the repository at this point in the history
Project-wide improvements
  • Loading branch information
lihenggui authored Jun 26, 2023
2 parents f5d635e + e95a50e commit 6273e4d
Show file tree
Hide file tree
Showing 18 changed files with 71 additions and 157 deletions.
29 changes: 14 additions & 15 deletions .github/workflows/Build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,41 @@ 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

- 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()
uses: actions/upload-artifact@v3
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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions app-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
27 changes: 0 additions & 27 deletions app-compose/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 0 additions & 9 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
with(pluginManager) {
apply("com.android.application")
apply("org.jetbrains.kotlin.android")
apply("blocker.android.lint")
}
extensions.configure<ApplicationExtension> {
configureKotlinAndroid(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,6 +35,7 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")
apply("blocker.android.lint")
}
extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
Expand All @@ -52,13 +52,6 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
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"))
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Project> {
override fun apply(target: Project) {
with(target) {
when {
pluginManager.hasPlugin("com.android.application") ->
configure<ApplicationExtension> { lint(Lint::configure) }

pluginManager.hasPlugin("com.android.library") ->
configure<LibraryExtension> { lint(Lint::configure) }

else -> {
pluginManager.apply("com.android.lint")
configure<Lint>(Lint::configure)
}
}
}
}
}

private fun Lint.configure() {
xmlReport = true
checkDependencies = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class JvmLibraryConventionPlugin : Plugin<Project> {
with(target) {
with(pluginManager) {
apply("org.jetbrains.kotlin.jvm")
apply("blocker.android.lint")
}
configureKotlinJvm()
}
Expand Down
21 changes: 0 additions & 21 deletions core/component-controller/proguard-rules.pro

This file was deleted.

3 changes: 0 additions & 3 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ android {
defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
lint {
checkDependencies = true
}
namespace = "com.merxury.blocker.core.designsystem"
}

Expand Down
14 changes: 0 additions & 14 deletions core/ifw-api/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 0 additions & 21 deletions core/provider/proguard-rules.pro

This file was deleted.

21 changes: 0 additions & 21 deletions core/rule/proguard-rules.pro

This file was deleted.

5 changes: 1 addition & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lint/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6273e4d

Please sign in to comment.