Files
fuzhu/order/build.gradle
2021-09-22 10:02:44 +08:00

91 lines
3.4 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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')
}