接上一篇 深入浅出Android Gradle构建系统(三:build task)
Android Gradle插件提供了大量的DSL来自定义构建过程,这篇blog就来讲解如何在gradle中配置manifest。
Instrumentation test runner
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
versionCode 12
versionName "2.0"
minSdkVersion 16
targetSdkVersion 16
}
}def computeVersionName() {
...
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
versionCode 12
versionName computeVersionName()
minSdkVersion 16
targetSdkVersion 16
}
}| Property Name | Default value in DSL object | Default value |
| versionCode | -1 | value from manifest if present |
| versionName | null | value from manifest if present |
| minSdkVersion | -1 | value from manifest if present |
| targetSdkVersion | -1 | value from manifest if present |
| applicationId | null | value from manifest if present |
| testApplicationId | null | applicationId + “.test” |
| testInstrumentationRunner | null | android.test.InstrumentationTestRunner |
| signingConfig | null | null |
| proguardFile | N/A (set only) | N/A (set only) |
| proguardFiles | N/A (set only) | N/A (set only) |
if (android.defaultConfig.testInstrumentationRunner == null) {
// assign a better default...
}如果属性的值仍然是null,那么在构建的时候,就会使用第三列的默认值,但是DSL元素中并不包含这些默认值,因此你不能在程序中查询这些值。这样做的目的是仅在必要的时候(构建时)才会去解析manifest内容。android-gradle-深入浅出四:自定义构建过程之配置manifest
原文地址:http://blog.csdn.net/lzyzsd/article/details/42567189