91 lines
3.4 KiB
Groovy
91 lines
3.4 KiB
Groovy
|
|
if (isRelease) { // 如果是发布版本时,各个模块都不能独立运行
|
|||
|
|
apply plugin: 'com.android.library'
|
|||
|
|
} else {
|
|||
|
|
apply plugin: 'com.android.application'
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
android {
|
|||
|
|
compileSdkVersion app_android.compileSdkVersion
|
|||
|
|
buildToolsVersion app_android.buildToolsVersion
|
|||
|
|
defaultConfig {
|
|||
|
|
// applicationId app_appid.order
|
|||
|
|
if (!isRelease) { // 如果是集成化模式,不能有applicationId
|
|||
|
|
applicationId app_appid.order // 组件化模式能独立运行才能有applicationId
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
minSdkVersion app_android.minSdkVersion
|
|||
|
|
targetSdkVersion app_android.targetSdkVersion
|
|||
|
|
versionCode app_android.versionCode
|
|||
|
|
versionName app_android.versionName
|
|||
|
|
testInstrumentationRunner app_android.testInstrumentationRunner
|
|||
|
|
|
|||
|
|
// 这个方法接收三个非空的参数,第一个:确定值的类型,第二个:指定key的名字,第三个:传值(必须是String)
|
|||
|
|
// 为什么需要定义这个?因为src代码中有可能需要用到跨模块交互,如果是组件化模块显然不行
|
|||
|
|
// 切记:不能在android根节点,只能在defaultConfig或buildTypes节点下
|
|||
|
|
buildConfigField("boolean", "isRelease", String.valueOf(isRelease))
|
|||
|
|
|
|||
|
|
// 都是为了 传递给 注解处理器
|
|||
|
|
// 在gradle文件中配置选项参数值(用于APT传参接收)
|
|||
|
|
// 同学们注意:切记:必须写在defaultConfig节点下
|
|||
|
|
javaCompileOptions {
|
|||
|
|
annotationProcessorOptions {
|
|||
|
|
// project.getName() == order
|
|||
|
|
// this.project.getName() == order
|
|||
|
|
// this.getProject().getName() == order
|
|||
|
|
arguments = [moduleName: project.getName(), packageNameForAPT: packageNameForAPT]
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
buildTypes {
|
|||
|
|
release {
|
|||
|
|
minifyEnabled false
|
|||
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 配置资源路径,方便测试环境,打包不集成到正式环境
|
|||
|
|
sourceSets {
|
|||
|
|
main {
|
|||
|
|
if (!isRelease) {
|
|||
|
|
// 如果是组件化模式,需要单独运行时
|
|||
|
|
manifest.srcFile 'src/main/debug/AndroidManifest.xml'
|
|||
|
|
} else {
|
|||
|
|
// 集成化模式,整个项目打包apk
|
|||
|
|
manifest.srcFile 'src/main/AndroidManifest.xml'
|
|||
|
|
java {
|
|||
|
|
// release 时 debug 目录下文件不需要合并到主工程
|
|||
|
|
exclude '**/debug/**'
|
|||
|
|
}
|
|||
|
|
// resources {
|
|||
|
|
// exclude '**/debug/**'
|
|||
|
|
// }
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
dependencies {
|
|||
|
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|||
|
|
|
|||
|
|
/*implementation 'androidx.appcompat:appcompat:1.1.0'
|
|||
|
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'*/
|
|||
|
|
|
|||
|
|
// 循环引入第三方库
|
|||
|
|
app_dependencies.each {k, v ->implementation v}
|
|||
|
|
|
|||
|
|
testImplementation 'junit:junit:4.12'
|
|||
|
|
androidTestImplementation 'androidx.test:runner:1.2.0'
|
|||
|
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
|||
|
|
|
|||
|
|
// 公共基础库
|
|||
|
|
implementation project(":common")
|
|||
|
|
|
|||
|
|
// 注解模块
|
|||
|
|
implementation project(":arouter_annotation")
|
|||
|
|
|
|||
|
|
// 使用注解处理器
|
|||
|
|
// 注解处理器
|
|||
|
|
annotationProcessor project(':arouter_compiler')
|
|||
|
|
}
|