From 337f7fa15e9ba58f39acd651bab2b65018b3e26b Mon Sep 17 00:00:00 2001 From: Quyunshuo Date: Sun, 20 Aug 2023 20:23:09 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E7=89=88=E6=9C=AC=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=201.=20agp=20->=20v8.1.0=202.=20gradle=20->?= =?UTF-8?q?=20v8.0=203.=20=E6=B7=BB=E5=8A=A0=20gradle=20version=20catalogs?= =?UTF-8?q?=20=E7=AE=A1=E7=90=86=E4=BE=9D=E8=B5=96=EF=BC=8C=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=20buildSrc=20=E6=96=B9=E5=BC=8F=EF=BC=8C=E7=9B=AE?= =?UTF-8?q?=E5=89=8D=E5=8F=AA=E5=B0=86=E6=8F=92=E4=BB=B6=E9=83=A8=E5=88=86?= =?UTF-8?q?=E9=87=8D=E6=9E=84=EF=BC=8C=E5=85=B6=E4=BD=99=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=90=8E=E7=BB=AD=E7=89=88=E6=9C=AC=E4=B8=AD=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +-- app/build.gradle | 28 ++++++------- app/proguard-rules.pro | 39 ++++++++----------- base_lib.gradle | 11 ++---- base_module.gradle | 22 +++-------- build.gradle | 28 ------------- build.gradle.kts | 8 ++++ buildSrc/build.gradle.kts | 2 +- .../buildsrc/DependencyConfig.kt | 8 ++-- .../buildsrc/ProjectBuildConfig.kt | 4 +- .../buildsrc/ProjectPluginManager.kt | 14 ------- gradle.properties | 5 ++- gradle/libs.versions.toml | 20 ++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- lib_base/build.gradle | 8 +++- lib_common/build.gradle | 7 ++++ module_home/build.gradle | 13 +++++++ settings.gradle.kts | 21 ++++++++++ 18 files changed, 130 insertions(+), 115 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/ProjectPluginManager.kt create mode 100644 gradle/libs.versions.toml diff --git a/README.md b/README.md index a6ed296..e2d4865 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Demo -​ 以鸿洋大神的玩安卓开放Api做的一款极简风格的玩安卓,仓库地址:[WanAndroidMVVM](https://github.com/Quyunshuo/WanAndroidMVVM),该项目正在开发中,由于工作较忙需要一段时间才能完成。如果想看旧版本的demo,可以直接打开demo分支看。 +​ 以鸿洋大神的玩安卓开放Api做了简单的页面示例,仓库地址:[WanAndroidMVVM](https://github.com/Quyunshuo/WanAndroidMVVM) ## 框架图示 @@ -387,5 +387,4 @@ fun test() { 三方库源码笔记(13)-可能是全网第一篇 Coil 的源码分析文章:[https://juejin.cn/post/6897872882051842061](https://juejin.cn/post/6897872882051842061) -【奇技淫巧】新的图片加载库?基于Kotlin协程的图片加载库——Coil:[https://juejin.cn/post/6844904159527829518](https://juejin.cn/post/6844904159527829518) - +【奇技淫巧】新的图片加载库?基于Kotlin协程的图片加载库——Coil:[https://juejin.cn/post/6844904159527829518](https://juejin.cn/post/6844904159527829518) \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d6d3e63..64541e9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,28 +4,31 @@ import com.quyunshuo.androidbaseframemvvm.buildsrc.* -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'com.alibaba.arouter' -apply plugin: 'kotlin-kapt' -apply plugin: 'dagger.hilt.android.plugin' +plugins { + alias(libs.plugins.application) + alias(libs.plugins.kotlin) + alias(libs.plugins.hilt) + id "kotlin-kapt" +} android { - compileSdkVersion ProjectBuildConfig.compileSdkVersion + namespace 'com.quyunshuo.androidbaseframemvvm' + compileSdk ProjectBuildConfig.compileSdkVersion defaultConfig { applicationId ProjectBuildConfig.applicationId - minSdkVersion ProjectBuildConfig.minSdkVersion - targetSdkVersion ProjectBuildConfig.targetSdkVersion + minSdk ProjectBuildConfig.minSdkVersion + targetSdk ProjectBuildConfig.targetSdkVersion versionCode ProjectBuildConfig.versionCode versionName ProjectBuildConfig.versionName + testInstrumentationRunner DependencyConfig.AndroidX.AndroidJUnitRunner multiDexKeepProguard file("multidexKeep.pro") ndk { // 设置支持的SO库架构 //abiFilters 'armeabi', 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a' - abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86','x86_64' + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' } } @@ -74,14 +77,13 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '17' } - namespace 'com.quyunshuo.androidbaseframemvvm' } dependencies { diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 54587e5..182dc6d 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,27 +1,20 @@ -# 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 - # 避免 ViewBinding 类被混淆导致反射初始化失败 -keep public interface androidx.viewbinding.ViewBinding -keepclassmembers class * implements androidx.viewbinding.ViewBinding{ *; -} \ No newline at end of file +} + +# AGP 8.x 警告生成 +# Please add these rules to your existing keep rules in order to suppress warnings. +# This is generated automatically by the Android Gradle plugin. +-dontwarn dalvik.system.VMStack +-dontwarn javax.lang.model.element.Element +-dontwarn org.bouncycastle.jsse.BCSSLParameters +-dontwarn org.bouncycastle.jsse.BCSSLSocket +-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider +-dontwarn org.conscrypt.Conscrypt$Version +-dontwarn org.conscrypt.Conscrypt +-dontwarn org.conscrypt.ConscryptHostnameVerifier +-dontwarn org.openjsse.javax.net.ssl.SSLParameters +-dontwarn org.openjsse.javax.net.ssl.SSLSocket +-dontwarn org.openjsse.net.ssl.OpenJSSE \ No newline at end of file diff --git a/base_lib.gradle b/base_lib.gradle index b6e8ffb..da87424 100644 --- a/base_lib.gradle +++ b/base_lib.gradle @@ -4,11 +4,6 @@ import com.quyunshuo.androidbaseframemvvm.buildsrc.* -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-kapt' -apply plugin: 'dagger.hilt.android.plugin' - android { compileSdkVersion ProjectBuildConfig.compileSdkVersion @@ -28,12 +23,12 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() + jvmTarget = "17" } buildTypes { diff --git a/base_module.gradle b/base_module.gradle index e7683a4..94db467 100644 --- a/base_module.gradle +++ b/base_module.gradle @@ -4,22 +4,12 @@ import com.quyunshuo.androidbaseframemvvm.buildsrc.* -if (ProjectBuildConfig.isAppMode) { - apply plugin: 'com.android.application' -} else { - apply plugin: 'com.android.library' -} - -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-kapt' -apply plugin: 'dagger.hilt.android.plugin' - android { - compileSdkVersion ProjectBuildConfig.compileSdkVersion + compileSdk ProjectBuildConfig.compileSdkVersion defaultConfig { - minSdkVersion ProjectBuildConfig.minSdkVersion - targetSdkVersion ProjectBuildConfig.targetSdkVersion + minSdk ProjectBuildConfig.minSdkVersion + targetSdk ProjectBuildConfig.targetSdkVersion versionCode ProjectBuildConfig.versionCode versionName ProjectBuildConfig.versionName testInstrumentationRunner DependencyConfig.AndroidX.AndroidJUnitRunner @@ -32,12 +22,12 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() + jvmTarget = "17" } buildFeatures { diff --git a/build.gradle b/build.gradle deleted file mode 100644 index db0cbed..0000000 --- a/build.gradle +++ /dev/null @@ -1,28 +0,0 @@ -import com.quyunshuo.androidbaseframemvvm.buildsrc.* - -buildscript { - repositories { - google() - jcenter() - mavenCentral() - maven { url 'https://maven.google.com' } - } - dependencies { - classpath ProjectPluginManager.AndroidToolsPlugin - classpath ProjectPluginManager.KotlinPlugin - classpath ProjectPluginManager.ARouterRegister - classpath ProjectPluginManager.HiltPlugin - } -} - -allprojects { - repositories { - google() - jcenter() - mavenCentral() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..468f122 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,8 @@ +@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed +plugins { + alias(libs.plugins.application) apply false + alias(libs.plugins.library) apply false + alias(libs.plugins.kotlin) apply false + alias(libs.plugins.hilt) apply false +} +true // Needed to make the Suppress annotation work for the plugins block \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index ae6c6e6..b393cee 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,2 +1,2 @@ plugins { `kotlin-dsl` } -repositories { jcenter() } \ No newline at end of file +repositories { mavenCentral() } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/DependencyConfig.kt b/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/DependencyConfig.kt index 4eb279c..9fe137a 100644 --- a/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/DependencyConfig.kt +++ b/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/DependencyConfig.kt @@ -22,8 +22,8 @@ object DependencyConfig { const val ConstraintLayout = "2.1.3" // 约束布局 const val TestExtJunit = "1.1.2" const val TestEspresso = "3.3.0" - const val ActivityKtx = "1.4.0" - const val FragmentKtx = "1.4.1" + const val ActivityKtx = "1.5.1" + const val FragmentKtx = "1.5.2" const val MultiDex = "2.0.1" // Android--------------------------------------------------------------- @@ -35,8 +35,8 @@ object DependencyConfig { const val Coroutines = "1.6.1" // 协程 // JetPack--------------------------------------------------------------- - const val Lifecycle = "2.4.1" // Lifecycle相关(ViewModel & LiveData & Lifecycle) - const val Hilt = "2.38.1" // DI框架-Hilt + const val Lifecycle = "2.4.1" // Lifecycle + const val Hilt = "2.44" // DI框架-Hilt // GitHub---------------------------------------------------------------- const val OkHttp = "4.9.0" // OkHttp diff --git a/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/ProjectBuildConfig.kt b/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/ProjectBuildConfig.kt index b405a93..8dfac24 100644 --- a/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/ProjectBuildConfig.kt +++ b/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/ProjectBuildConfig.kt @@ -7,10 +7,10 @@ package com.quyunshuo.androidbaseframemvvm.buildsrc * @since 4/24/21 5:56 PM */ object ProjectBuildConfig { - const val compileSdkVersion = 31 + const val compileSdkVersion = 33 const val applicationId = "com.quyunshuo.androidbaseframemvvm" const val minSdkVersion = 21 - const val targetSdkVersion = 31 + const val targetSdkVersion = 33 const val versionCode = 1 const val versionName = "1.0" const val isAppMode = false diff --git a/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/ProjectPluginManager.kt b/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/ProjectPluginManager.kt deleted file mode 100644 index 37b20dd..0000000 --- a/buildSrc/src/main/kotlin/com/quyunshuo/androidbaseframemvvm/buildsrc/ProjectPluginManager.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.quyunshuo.androidbaseframemvvm.buildsrc - -/** - * 项目级插件管理 - * - * @author Qu Yunshuo - * @since 4/24/21 5:56 PM - */ -object ProjectPluginManager { - const val AndroidToolsPlugin = "com.android.tools.build:gradle:7.2.0" - const val KotlinPlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21" - const val ARouterRegister = "com.alibaba:arouter-register:1.0.2" - const val HiltPlugin = "com.google.dagger:hilt-android-gradle-plugin:2.38.1" -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 4d15d01..fde9fa4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,7 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..4732a7d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,20 @@ +[versions] +# plugin +agp = "8.1.0" +kotlin-android = "1.8.0" +hilt = "2.44" + +#lib + + +[libraries] + + +[plugins] +application = { id = "com.android.application", version.ref = "agp" } +library = { id = "com.android.library", version.ref = "agp" } +kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin-android" } +hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } + + +[bundles] \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d153fba..1640461 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip diff --git a/lib_base/build.gradle b/lib_base/build.gradle index fcd1031..6fa0d77 100644 --- a/lib_base/build.gradle +++ b/lib_base/build.gradle @@ -2,8 +2,14 @@ //********** lib_base 的配置文件 *********** //**************************************** +plugins { + alias(libs.plugins.library) + alias(libs.plugins.kotlin) + alias(libs.plugins.hilt) + id "kotlin-kapt" +} + apply from: '../base_lib.gradle' -apply plugin: 'dagger.hilt.android.plugin' import com.quyunshuo.androidbaseframemvvm.buildsrc.* diff --git a/lib_common/build.gradle b/lib_common/build.gradle index 145e452..f1d607d 100644 --- a/lib_common/build.gradle +++ b/lib_common/build.gradle @@ -2,6 +2,13 @@ //********* lib_common 的配置文件 ********** //**************************************** +plugins { + alias(libs.plugins.library) + alias(libs.plugins.kotlin) + alias(libs.plugins.hilt) + id "kotlin-kapt" +} + apply from: '../base_lib.gradle' import com.quyunshuo.androidbaseframemvvm.buildsrc.* diff --git a/module_home/build.gradle b/module_home/build.gradle index b9c2de4..83fe5f2 100644 --- a/module_home/build.gradle +++ b/module_home/build.gradle @@ -1,7 +1,20 @@ +import com.quyunshuo.androidbaseframemvvm.buildsrc.ProjectBuildConfig + //**************************************** //******** module_home 的配置文件 ********* //**************************************** +plugins { + alias(libs.plugins.kotlin) + alias(libs.plugins.hilt) + id "kotlin-kapt" +} +if (ProjectBuildConfig.isAppMode) { + apply plugin: 'com.android.application' +} else { + apply plugin: 'com.android.library' +} + apply from: '../base_module.gradle' android { diff --git a/settings.gradle.kts b/settings.gradle.kts index b42c725..d04aa91 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,24 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + maven { url = java.net.URI.create("https://maven.google.com") } + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + gradlePluginPortal() + maven { url = java.net.URI.create("https://maven.google.com") } + } +} + +rootProject.name = "AndroidBaseFrameMVVM" + include( ":app", ":lib_base",