[desc]:抽象公共配置

[author]:wangyimiao
master
yimiao 3 years ago
parent aaf76a2ab7
commit 8216c12bd7

@ -5,16 +5,19 @@ plugins {
id 'kotlin-kapt' id 'kotlin-kapt'
} }
apply from: "${rootProject.rootDir}/buildCommon/commonLibConfig.gradle"
project.ext.setArouterConfig project
android { android {
compileSdkVersion rootProject.ext.android.compileSdkVersion compileSdkVersion rootProject.ext.versions.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion buildToolsVersion rootProject.ext.versions.buildToolsVersion
defaultConfig { defaultConfig {
applicationId "com.common.commonlibtest" applicationId "com.common.commonlibtest"
minSdkVersion rootProject.ext.android.minSdkVersion minSdkVersion rootProject.ext.versions.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion targetSdkVersion rootProject.ext.versions.targetSdkVersion
versionCode rootProject.ext.android.versionCode versionCode rootProject.ext.versions.versionCode
versionName rootProject.ext.android.versionName versionName rootProject.ext.versions.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
@ -52,10 +55,11 @@ android {
} }
dependencies { dependencies {
implementation project(path: ':commonLib')
implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0' implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(path: ':commonLib')
// kotlin // kotlin
implementation rootProject.ext.dependencies.kotlin implementation rootProject.ext.dependencies.kotlin

@ -1,5 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // 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 { buildscript {
repositories { repositories {
google() google()

@ -1,13 +1,4 @@
ext { project.ext {
android = [
compileSdkVersion: 30,
buildToolsVersion: "30.0.3",
minSdkVersion : 23,
targetSdkVersion : 28,
versionCode : 1,
versionName : "1.0"
]
sign = [ sign = [
keystore_path : "../innovationapp.jks", keystore_path : "../innovationapp.jks",
keystore_pwd : "123456", keystore_pwd : "123456",
@ -20,6 +11,14 @@ ext {
] ]
versions = [ versions = [
compileSdkVersion : 30,
buildToolsVersion : "30.0.3",
minSdkVersion : 23,
targetSdkVersion : 28,
versionCode : 1,
versionName : "1.0",
jvmTarget : "1.8",
appcompat : "1.2.0", appcompat : "1.2.0",
material : "1.2.1", material : "1.2.1",
okhttp : "4.9.1", okhttp : "4.9.1",
@ -38,6 +37,7 @@ ext {
luban : "1.1.8", luban : "1.1.8",
kotlin_android : "1.4.1", kotlin_android : "1.4.1",
gson : "2.8.6", gson : "2.8.6",
arouter : "1.5.2",
] ]
dependencies = [ dependencies = [
@ -63,5 +63,77 @@ ext {
photo_view : "com.github.chrisbanes:PhotoView:${versions.photo_view}", photo_view : "com.github.chrisbanes:PhotoView:${versions.photo_view}",
luban : "top.zibin:Luban:${versions.luban}", luban : "top.zibin:Luban:${versions.luban}",
gson : "com.google.code.gson:gson${versions.gson}", 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
}
} }

@ -1,22 +1,7 @@
plugins { apply from: "${rootProject.rootDir}/buildCommon/commonLibConfig.gradle"
id 'com.android.library' project.ext.setLibDefaultConfig project
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}
android { 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 { buildTypes {
debug { debug {
minifyEnabled false minifyEnabled false
@ -29,15 +14,6 @@ android {
buildConfigField 'String', 'BASE_URL_CONFIG_PATH', '"baseUrl.properties"' buildConfigField 'String', 'BASE_URL_CONFIG_PATH', '"baseUrl.properties"'
} }
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
androidExtensions {
// kotlin
experimental = true
}
} }
dependencies { dependencies {

@ -1,34 +1,16 @@
plugins { apply from: "${rootProject.rootDir}/buildCommon/commonLibConfig.gradle"
id 'com.android.library' project.ext.setLibDefaultConfig project
id 'kotlin-android'
id 'kotlin-parcelize'
}
android { 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 { buildTypes {
release { release {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 buildFeatures {
targetCompatibility JavaVersion.VERSION_1_8 viewBinding true
}
viewBinding {
enabled = true
} }
} }

Loading…
Cancel
Save