diff --git a/app/build.gradle b/app/build.gradle index e3569ab..8350a40 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,16 +5,19 @@ plugins { id 'kotlin-kapt' } +apply from: "${rootProject.rootDir}/buildCommon/commonLibConfig.gradle" +project.ext.setArouterConfig project + android { - compileSdkVersion rootProject.ext.android.compileSdkVersion - buildToolsVersion rootProject.ext.android.buildToolsVersion + compileSdkVersion rootProject.ext.versions.compileSdkVersion + buildToolsVersion rootProject.ext.versions.buildToolsVersion defaultConfig { applicationId "com.common.commonlibtest" - minSdkVersion rootProject.ext.android.minSdkVersion - targetSdkVersion rootProject.ext.android.targetSdkVersion - versionCode rootProject.ext.android.versionCode - versionName rootProject.ext.android.versionName + minSdkVersion rootProject.ext.versions.minSdkVersion + targetSdkVersion rootProject.ext.versions.targetSdkVersion + versionCode rootProject.ext.versions.versionCode + versionName rootProject.ext.versions.versionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -52,10 +55,11 @@ android { } dependencies { + implementation project(path: ':commonLib') + implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - implementation project(path: ':commonLib') // 添加kotlin依赖 implementation rootProject.ext.dependencies.kotlin diff --git a/build.gradle b/build.gradle index db66d8a..c3d7d14 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -apply from: "commonLibConfig.gradle" +apply from: "${rootProject.rootDir}/buildCommon/commonLibConfig.gradle" buildscript { repositories { google() diff --git a/commonLibConfig.gradle b/buildCommon/commonLibConfig.gradle similarity index 54% rename from commonLibConfig.gradle rename to buildCommon/commonLibConfig.gradle index bc75804..61743b7 100644 --- a/commonLibConfig.gradle +++ b/buildCommon/commonLibConfig.gradle @@ -1,13 +1,4 @@ -ext { - android = [ - compileSdkVersion: 30, - buildToolsVersion: "30.0.3", - minSdkVersion : 23, - targetSdkVersion : 28, - versionCode : 1, - versionName : "1.0" - ] - +project.ext { sign = [ keystore_path : "../innovationapp.jks", keystore_pwd : "123456", @@ -20,6 +11,14 @@ ext { ] versions = [ + compileSdkVersion : 30, + buildToolsVersion : "30.0.3", + minSdkVersion : 23, + targetSdkVersion : 28, + versionCode : 1, + versionName : "1.0", + jvmTarget : "1.8", + appcompat : "1.2.0", material : "1.2.1", okhttp : "4.9.1", @@ -38,6 +37,7 @@ ext { luban : "1.1.8", kotlin_android : "1.4.1", gson : "2.8.6", + arouter : "1.5.2", ] dependencies = [ @@ -63,5 +63,77 @@ ext { photo_view : "com.github.chrisbanes:PhotoView:${versions.photo_view}", luban : "top.zibin:Luban:${versions.luban}", gson : "com.google.code.gson:gson${versions.gson}", + arouter : "com.alibaba:arouter-api:${versions.arouter}", + arouter_compiler : "com.alibaba:arouter-compiler:${versions.arouter}", + ] + + /** + * android project android {} default config + */ + setAndroidConfig = { + extension -> + extension.compileSdkVersion versions.compileSdkVersion + + extension.defaultConfig { + minSdkVersion versions.minSdkVersion + targetSdkVersion versions.targetSdkVersion + versionCode versions.versionCode + versionName versions.vserionName + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + extension.compileOptions { + targetCompatibility = compileOptions.targetCompatibility + sourceCompatibility = compileOptions.sourceCompatibility + } + + extension.kotlinOptions { + jvmTarget = versions.jvmTarget + } + } + + /** + * android project dependencies {} default config + */ + setDependencies = { + extension -> + extension.implementation fileTree(include: ['*.jar'], dir: 'libs') + } + + /** + * android library default config + */ + setLibDefaultConfig = { + extension -> + extension.apply plugin: 'com.android.library' + extension.apply plugin: 'kotlin-android' + extension.apply plugin: 'kotlin-parcelize' + extension.apply plugin: 'kotlin-kapt' + extension.description "lib" + + setAndroidConfig extension.android + setDependencies extension.dependencies + } + + /** + * android library common config + */ + setArouterConfig = { + extension -> + extension.android.defaultConfig { + javaCompileOptions { + annotationProcessorOptions { + arguments = [AROUTER_MODULE_NAME: project.getName()] + } + } + } + + // 添加ARouter依赖 + extension.dependencies.implementation(rootProject.ext.dependencies.arouter) { + exclude group: 'com.android.support' + } + extension.dependencies.annotationProcessor rootProject.ext.dependencies.arouter_compiler + } } \ No newline at end of file diff --git a/commonLib/build.gradle b/commonLib/build.gradle index c5c306a..e7db58a 100644 --- a/commonLib/build.gradle +++ b/commonLib/build.gradle @@ -1,22 +1,7 @@ -plugins { - id 'com.android.library' - id 'kotlin-android' - id 'kotlin-android-extensions' - id 'kotlin-kapt' -} +apply from: "${rootProject.rootDir}/buildCommon/commonLibConfig.gradle" +project.ext.setLibDefaultConfig project android { - compileSdkVersion rootProject.ext.android.compileSdkVersion - buildToolsVersion rootProject.ext.android.buildToolsVersion - - defaultConfig { - minSdkVersion rootProject.ext.android.minSdkVersion - targetSdkVersion rootProject.ext.android.targetSdkVersion - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles "consumer-rules.pro" - } - buildTypes { debug { minifyEnabled false @@ -29,15 +14,6 @@ android { buildConfigField 'String', 'BASE_URL_CONFIG_PATH', '"baseUrl.properties"' } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - androidExtensions { - // kotlin序列化 - experimental = true - } } dependencies { diff --git a/commonbt/build.gradle b/commonbt/build.gradle index 37559f3..5fe86e0 100644 --- a/commonbt/build.gradle +++ b/commonbt/build.gradle @@ -1,34 +1,16 @@ -plugins { - id 'com.android.library' - id 'kotlin-android' - id 'kotlin-parcelize' -} +apply from: "${rootProject.rootDir}/buildCommon/commonLibConfig.gradle" +project.ext.setLibDefaultConfig project android { - compileSdkVersion rootProject.ext.android.compileSdkVersion - buildToolsVersion rootProject.ext.android.buildToolsVersion - - defaultConfig { - minSdkVersion rootProject.ext.android.minSdkVersion - targetSdkVersion rootProject.ext.android.targetSdkVersion - versionCode rootProject.ext.android.versionCode - versionName rootProject.ext.android.versionName - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - viewBinding { - enabled = true + + buildFeatures { + viewBinding true } }