Skip to content

Commit

Permalink
build: 修改gradle脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
goweii committed Mar 27, 2022
1 parent 5b116af commit 5b81f66
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 47 deletions.
30 changes: 1 addition & 29 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ apply plugin: 'bugly'
apply from: "../module.gradle"
apply from: "../flavor.gradle"

Properties properties = new Properties()
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream()
properties.load(inputStream)

android {
defaultConfig {
renderscriptTargetApi rootProject.ext.android.minSdkVersion
Expand All @@ -21,30 +17,6 @@ android {
}
}
}
signingConfigs {
release {
storeFile file(properties.getProperty('KEYSTORE_FILE'))
storePassword properties.getProperty('KEYSTORE_FILE_PASSWORD')
keyAlias properties.getProperty('KEYSTORE_ALIAS')
keyPassword properties.getProperty('KEYSTORE_ALIAS_PASSWORD')
}
debug {
storeFile file(properties.getProperty('KEYSTORE_FILE'))
storePassword properties.getProperty('KEYSTORE_FILE_PASSWORD')
keyAlias properties.getProperty('KEYSTORE_ALIAS')
keyPassword properties.getProperty('KEYSTORE_ALIAS_PASSWORD')
}
}
buildTypes {
release {
shrinkResources false
signingConfig signingConfigs.release
}
debug {
shrinkResources false
signingConfig signingConfigs.debug
}
}
resourcePrefix ""
applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand All @@ -65,7 +37,7 @@ bugly {
}

repositories {
flatDir { dirs 'libs' }
flatDir { dirs 'libs' }
}

dependencies {
Expand Down
111 changes: 93 additions & 18 deletions flavor.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,111 @@
Properties properties = new Properties()
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream()
properties.load(inputStream)
def KEYSTORE_FILE = ""
def KEYSTORE_FILE_PASSWORD = ""
def KEYSTORE_ALIAS = ""
def KEYSTORE_ALIAS_PASSWORD = ""

def APPID_BUGLY_FOR_PER = ""
def APPKEY_BUGLY_FOR_PER = ""
def APPID_BUGLY_FOR_COM = ""
def APPKEY_BUGLY_FOR_COM = ""

def CDKEY_CLASS = ""
def DEVELOPER_ID = ""

def WANPWD_FORMAT = ""
def WANPWD_PATTERN = ""
def WANPWD_TYPE_CREATE_CDKEY = ""
def WANPWD_TYPE_QQ = ""
def WANPWD_TYPE_FESTIVAL = ""
def WANPWD_TYPE_USERPAGE = ""
def WANPWD_TYPE_CDKEY = ""
def WANPWD_TYPE_WEB = ""
def WANPWD_TYPE_ABOUTME = ""

if (project.rootProject.file('local.properties').exists()) {
Properties properties = new Properties()
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream()
properties.load(inputStream)

KEYSTORE_FILE = properties.getProperty('KEYSTORE_FILE')
KEYSTORE_FILE_PASSWORD = properties.getProperty('KEYSTORE_FILE_PASSWORD')
KEYSTORE_ALIAS = properties.getProperty('KEYSTORE_ALIAS')
KEYSTORE_ALIAS_PASSWORD = properties.getProperty('KEYSTORE_ALIAS_PASSWORD')

APPID_BUGLY_FOR_PER = properties.getProperty('APPID_BUGLY_FOR_PER')
APPKEY_BUGLY_FOR_PER = properties.getProperty('APPKEY_BUGLY_FOR_PER')
APPID_BUGLY_FOR_COM = properties.getProperty('APPID_BUGLY_FOR_COM')
APPKEY_BUGLY_FOR_COM = properties.getProperty('APPKEY_BUGLY_FOR_COM')

WANPWD_FORMAT = properties.getProperty('WANPWD_FORMAT')
WANPWD_PATTERN = properties.getProperty('WANPWD_PATTERN')
WANPWD_TYPE_QQ = properties.getProperty('WANPWD_TYPE_QQ')
WANPWD_TYPE_FESTIVAL = properties.getProperty('WANPWD_TYPE_FESTIVAL')
WANPWD_TYPE_USERPAGE = properties.getProperty('WANPWD_TYPE_USERPAGE')
WANPWD_TYPE_CDKEY = properties.getProperty('WANPWD_TYPE_CDKEY')
WANPWD_TYPE_WEB = properties.getProperty('WANPWD_TYPE_WEB')
WANPWD_TYPE_ABOUTME = properties.getProperty('WANPWD_TYPE_ABOUTME')
WANPWD_TYPE_CREATE_CDKEY = properties.getProperty('WANPWD_TYPE_CREATE_CDKEY')
CDKEY_CLASS = properties.getProperty('CDKEY_CLASS')
DEVELOPER_ID = properties.getProperty('DEVELOPER_ID')
}

android {
signingConfigs {
release {
if (KEYSTORE_FILE != null) {
storeFile file(KEYSTORE_FILE)
storePassword KEYSTORE_FILE_PASSWORD
keyAlias KEYSTORE_ALIAS
keyPassword KEYSTORE_ALIAS_PASSWORD
}
}
debug {
if (KEYSTORE_FILE != null) {
storeFile file(KEYSTORE_FILE)
storePassword KEYSTORE_FILE_PASSWORD
keyAlias KEYSTORE_ALIAS
keyPassword KEYSTORE_ALIAS_PASSWORD
}
}
}
buildTypes {
release {
shrinkResources false
signingConfig signingConfigs.release
}
debug {
shrinkResources false
signingConfig signingConfigs.debug
}
}
flavorDimensions "applicationId"
productFlavors {
per {
dimension "applicationId"
applicationId "per.goweii.wanandroid"
ext.buglyAppId = properties.getProperty('APPID_BUGLY_FOR_PER')
ext.buglyAppKey = properties.getProperty('APPKEY_BUGLY_FOR_PER')
ext.buglyAppId = APPID_BUGLY_FOR_PER
ext.buglyAppKey = APPKEY_BUGLY_FOR_PER
}
com {
dimension "applicationId"
applicationId "com.goweii.wanandroid"
ext.buglyAppId = properties.getProperty('APPID_BUGLY_FOR_COM')
ext.buglyAppKey = properties.getProperty('APPKEY_BUGLY_FOR_COM')
ext.buglyAppId = APPID_BUGLY_FOR_COM
ext.buglyAppKey = APPKEY_BUGLY_FOR_COM
}
}
productFlavors.all { flavor ->
buildConfigField "String", "APPID_BUGLY", "\"${ext.buglyAppId}\""
buildConfigField "String", "APPKEY_BUGLY", "\"${ext.buglyAppKey}\""
buildConfigField "String", "WANPWD_FORMAT", "\"${properties.getProperty('WANPWD_FORMAT')}\""
buildConfigField "String", "WANPWD_PATTERN", "\"${properties.getProperty('WANPWD_PATTERN')}\""
buildConfigField "String", "WANPWD_TYPE_QQ", "\"${properties.getProperty('WANPWD_TYPE_QQ')}\""
buildConfigField "String", "WANPWD_TYPE_FESTIVAL", "\"${properties.getProperty('WANPWD_TYPE_FESTIVAL')}\""
buildConfigField "String", "WANPWD_TYPE_USERPAGE", "\"${properties.getProperty('WANPWD_TYPE_USERPAGE')}\""
buildConfigField "String", "WANPWD_TYPE_CDKEY", "\"${properties.getProperty('WANPWD_TYPE_CDKEY')}\""
buildConfigField "String", "WANPWD_TYPE_WEB", "\"${properties.getProperty('WANPWD_TYPE_WEB')}\""
buildConfigField "String", "WANPWD_TYPE_ABOUTME", "\"${properties.getProperty('WANPWD_TYPE_ABOUTME')}\""
buildConfigField "String", "WANPWD_TYPE_CREATE_CDKEY", "\"${properties.getProperty('WANPWD_TYPE_CREATE_CDKEY')}\""
buildConfigField "String", "CDKEY_CLASS", "\"${properties.getProperty('CDKEY_CLASS')}\""
buildConfigField "String", "DEVELOPER_ID", "\"${properties.getProperty('DEVELOPER_ID')}\""
buildConfigField "String", "WANPWD_FORMAT", "\"${WANPWD_FORMAT}\""
buildConfigField "String", "WANPWD_PATTERN", "\"${WANPWD_PATTERN}\""
buildConfigField "String", "WANPWD_TYPE_QQ", "\"${WANPWD_TYPE_QQ}\""
buildConfigField "String", "WANPWD_TYPE_FESTIVAL", "\"${WANPWD_TYPE_FESTIVAL}\""
buildConfigField "String", "WANPWD_TYPE_USERPAGE", "\"${WANPWD_TYPE_USERPAGE}\""
buildConfigField "String", "WANPWD_TYPE_CDKEY", "\"${WANPWD_TYPE_CDKEY}\""
buildConfigField "String", "WANPWD_TYPE_WEB", "\"${WANPWD_TYPE_WEB}\""
buildConfigField "String", "WANPWD_TYPE_ABOUTME", "\"${WANPWD_TYPE_ABOUTME}\""
buildConfigField "String", "WANPWD_TYPE_CREATE_CDKEY", "\"${WANPWD_TYPE_CREATE_CDKEY}\""
buildConfigField "String", "CDKEY_CLASS", "\"${CDKEY_CLASS}\""
buildConfigField "String", "DEVELOPER_ID", "\"${DEVELOPER_ID}\""
}
}

0 comments on commit 5b81f66

Please sign in to comment.