Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
badbc7e3
Commit
badbc7e3
authored
Jul 29, 2021
by
shiyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配置多flavor进行环境切换运行
parent
8813a0a8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
69 additions
and
40 deletions
+69
-40
build.gradle
CommonLib/BCommon/build.gradle
+2
-15
GlobalConstants.kt
.../main/java/com/yidian/bcommon/constant/GlobalConstants.kt
+4
-2
RunConfig.kt
...on/src/main/java/com/yidian/bcommon/constant/RunConfig.kt
+1
-1
BaseInitConfig.kt
...main/java/com/yidian/shenghuoquan/broot/BaseInitConfig.kt
+7
-0
build.gradle
app/build.gradle
+37
-14
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+5
-6
BusinessApplication.kt
...ain/java/com/shenghuoquan/business/BusinessApplication.kt
+7
-0
config.gradle
config/config.gradle
+6
-2
No files found.
CommonLib/BCommon/build.gradle
View file @
badbc7e3
...
...
@@ -25,23 +25,10 @@ android {
consumerProguardFiles
"consumer-rules.pro"
}
buildTypes
{
debug
{
buildConfigField
(
"String"
,
"PROVIDER_NAME"
,
'\"'
+
rootProject
.
ext
.
android
.
applicationId
+
".debug.fileprovider"
+
'\"'
)
manifestPlaceholders
=
[
app_name
:
"商家版测试"
,
file_provider:
rootProject
.
ext
.
android
.
applicationId
+
".debug.fileprovider"
,
amap_key
:
rootProject
.
ext
.
amap
.
amap_debug_key
,
]
}
release
{
buildConfigField
(
"String"
,
"PROVIDER_NAME"
,
'\"'
+
rootProject
.
ext
.
android
.
applicationId
+
".fileprovider"
+
'\"'
)
manifestPlaceholders
=
[
app_name
:
"生活圈商家版"
,
file_provider:
rootProject
.
ext
.
android
.
applicationId
+
".fileprovider"
,
amap_key
:
rootProject
.
ext
.
amap
.
amap_release_key
,
]
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
}
compileOptions
{
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/constant/GlobalConstants.kt
View file @
badbc7e3
package
com.yidian.bcommon.constant
import
com.yidian.bcommon.BuildConfig
/**
* 全局的常量
...
...
@@ -12,6 +11,9 @@ interface GlobalConstants {
const
val
APK_NAME
=
"merchant-b.apk"
// 清单文件中FileProvider的authorities
const
val
AUTHORITY
=
BuildConfig
.
PROVIDER_NAME
var
ENVIRONMENT
=
""
// 清单文件中FileProvider的authorities
var
AUTHORITY
=
""
}
}
CommonLib/BCommon/src/main/java/com/yidian/bcommon/constant/RunConfig.kt
View file @
badbc7e3
...
...
@@ -12,7 +12,7 @@ object RunConfig {
PROD
// 生产环境
}
// 以下配置默认为开发环境,切记以下变量只能在此类中进行赋值,其他均为
适
用方
// 以下配置默认为开发环境,切记以下变量只能在此类中进行赋值,其他均为
使
用方
var
API_URL
=
AppConfig
.
DEV_DOMAIN
// 服务域名
var
IS_ENCRYPT
:
Boolean
=
false
// true : 开启加密
var
IS_ENCRYPT_DEBUG_KEY
=
true
// false: 使用正式加密key
...
...
Components/BRoot/src/main/java/com/yidian/shenghuoquan/broot/BaseInitConfig.kt
View file @
badbc7e3
...
...
@@ -7,6 +7,7 @@ import com.scwang.smart.refresh.layout.SmartRefreshLayout
import
com.scwang.smart.refresh.layout.constant.SpinnerStyle
import
com.yidian.bcommon.constant.AppConfig
import
com.yidian.bcommon.BuildConfig
import
com.yidian.bcommon.constant.GlobalConstants
import
com.yidian.bcommon.constant.RunConfig
import
com.yidian.bcommon.http.ApiSaveCookiesInterceptor
import
com.yidian.bcommon.http.ApiSetCookiesInterceptor
...
...
@@ -37,6 +38,12 @@ import timber.log.Timber
object
BaseInitConfig
{
fun
performInitialization
(
context
:
Context
)
{
// 使用编译器运行时,根据Flavor进行环境的配置切换
when
(
GlobalConstants
.
ENVIRONMENT
)
{
"dev"
->
RunConfig
.
switchEnvironment
(
RunConfig
.
RunEnvironment
.
DEV
)
"beta"
->
RunConfig
.
switchEnvironment
(
RunConfig
.
RunEnvironment
.
TEST
)
"prod"
->
RunConfig
.
switchEnvironment
(
RunConfig
.
RunEnvironment
.
PROD
)
}
// 初始化友盟
UMConfigUtils
.
init
(
context
)
if
(
ProcessUtil
.
isMainProcess
(
context
))
{
...
...
app/build.gradle
View file @
badbc7e3
...
...
@@ -33,13 +33,6 @@ android {
}
buildTypes
{
debug
{
applicationIdSuffix
".debug"
buildConfigField
(
"String"
,
"API_URL"
,
rootProject
.
ext
.
buildParams
.
debug
.
API_URL
)
buildConfigField
(
"String"
,
"PROVIDER_NAME"
,
'\"'
+
rootProject
.
ext
.
android
.
applicationId
+
".debug.fileprovider"
+
'\"'
)
manifestPlaceholders
=
[
app_name
:
"商家版测试"
,
file_provider:
rootProject
.
ext
.
android
.
applicationId
+
".debug.fileprovider"
,
]
//不混淆
minifyEnabled
false
//Zipalign优化
...
...
@@ -48,12 +41,6 @@ android {
signingConfig
signingConfigs
.
production
}
release
{
buildConfigField
(
"String"
,
"API_URL"
,
rootProject
.
ext
.
buildParams
.
release
.
API_URL
)
buildConfigField
(
"String"
,
"PROVIDER_NAME"
,
'\"'
+
rootProject
.
ext
.
android
.
applicationId
+
".fileprovider"
+
'\"'
)
manifestPlaceholders
=
[
app_name
:
"生活圈商家版"
,
file_provider:
rootProject
.
ext
.
android
.
applicationId
+
".fileprovider"
,
]
//混淆
minifyEnabled
true
//Zipalign优化
...
...
@@ -69,7 +56,42 @@ android {
}
}
}
flavorDimensions
"default"
productFlavors
{
dev
{
//开发
dimension
"default"
applicationId
rootProject
.
ext
.
android
.
applicationTestId
buildConfigField
(
"String"
,
"API_URL"
,
rootProject
.
ext
.
buildParams
.
dev
.
API_URL
)
buildConfigField
(
"String"
,
"PROVIDER_NAME"
,
'\"'
+
rootProject
.
ext
.
android
.
applicationTestId
+
".fileprovider"
+
'\"'
)
manifestPlaceholders
=
[
app_name
:
"商家版开发"
,
application_id:
rootProject
.
ext
.
android
.
applicationTestId
,
amap_key
:
rootProject
.
ext
.
amap
.
amap_debug_key
,
]
}
beta
{
//测试
dimension
"default"
applicationId
rootProject
.
ext
.
android
.
applicationTestId
buildConfigField
(
"String"
,
"API_URL"
,
rootProject
.
ext
.
buildParams
.
test
.
API_URL
)
buildConfigField
(
"String"
,
"PROVIDER_NAME"
,
'\"'
+
rootProject
.
ext
.
android
.
applicationTestId
+
".fileprovider"
+
'\"'
)
manifestPlaceholders
=
[
app_name
:
"商家版测试"
,
application_id:
rootProject
.
ext
.
android
.
applicationTestId
,
amap_key
:
rootProject
.
ext
.
amap
.
amap_debug_key
,
]
}
prod
{
//生产
dimension
"default"
applicationId
rootProject
.
ext
.
android
.
applicationId
buildConfigField
(
"String"
,
"API_URL"
,
rootProject
.
ext
.
buildParams
.
prod
.
API_URL
)
buildConfigField
(
"String"
,
"PROVIDER_NAME"
,
'\"'
+
rootProject
.
ext
.
android
.
applicationId
+
".fileprovider"
+
'\"'
)
manifestPlaceholders
=
[
app_name
:
"生活圈商家版"
,
application_id:
rootProject
.
ext
.
android
.
applicationId
,
amap_key
:
rootProject
.
ext
.
amap
.
amap_release_key
,
]
}
}
compileOptions
{
sourceCompatibility
JavaVersion
.
VERSION_1_8
targetCompatibility
JavaVersion
.
VERSION_1_8
...
...
@@ -107,6 +129,7 @@ dependencies {
implementation
project
(
it
)
}
if
(!
rootProject
.
ext
.
android
.
isApplication
)
{
implementation
project
(
":Components:BDemo"
)
implementation
project
(
":Components:BManagerCenter"
)
implementation
project
(
":Components:BGoods"
)
implementation
project
(
":Components:BXBridBusiness"
)
...
...
app/src/main/AndroidManifest.xml
View file @
badbc7e3
...
...
@@ -24,19 +24,18 @@
tools:targetApi=
"n"
>
<!-- 以下为友盟分享基本配置信息 start-->
<provider
android:name=
"androidx.core.content.FileProvider"
android:authorities=
"${
file_provider}
"
android:authorities=
"${
application_id}.fileprovider
"
android:exported=
"false"
android:grantUriPermissions=
"true"
tools:replace=
"android:authorities"
>
android:grantUriPermissions=
"true"
>
<meta-data
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:resource=
"@xml/file_paths"
tools:replace=
"android:resource"
/>
android:resource=
"@xml/file_paths"
/>
</provider>
<!-- 以下为友盟分享基本配置信息 start-->
<!--微信分享/登录-->
<activity
android:name=
".wxapi.WXEntryActivity"
...
...
app/src/main/java/com/shenghuoquan/business/BusinessApplication.kt
View file @
badbc7e3
...
...
@@ -6,6 +6,7 @@ import android.content.res.Configuration
import
android.os.Bundle
import
com.orhanobut.hawk.Hawk
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.constant.GlobalConstants
import
com.yidian.bcommon.services.AppUpgradeService
import
com.yidian.bcommon.services.ImageService
import
com.yidian.bcommon.services.XEventService
...
...
@@ -34,9 +35,15 @@ class BusinessApplication : YdBaseApplication() {
XPageManager
.
init
(
this
)
loadService
()
registerActivityLifecycleCallbacks
(
activityLifecycle
)
initEnvironment
()
}
}
private
fun
initEnvironment
()
{
GlobalConstants
.
ENVIRONMENT
=
BuildConfig
.
FLAVOR
GlobalConstants
.
AUTHORITY
=
BuildConfig
.
PROVIDER_NAME
}
override
fun
attachBaseContext
(
base
:
Context
?)
{
super
.
attachBaseContext
(
base
)
if
(
ProcessUtil
.
isMainProcess
(
this
))
{
...
...
config/config.gradle
View file @
badbc7e3
ext
{
android
=
[
applicationTestId:
"com.shenghuoquan.business.debug"
,
applicationId
:
"com.shenghuoquan.business"
,
versionCode
:
101
,
versionName
:
"1.0.1"
,
...
...
@@ -11,10 +12,13 @@ ext {
amap_release_key:
'9dc8e3fe44680c65de8dbfd808742b10'
,
]
buildParams
=
[
debug
:
[
dev
:
[
API_URL:
'"http://bp-dev.go2yd.com"'
,
],
test:
[
API_URL:
'"http://bp-test.go2yd.com"'
,
],
release
:
[
prod
:
[
API_URL:
'"https://bp.go2yd.com"'
,
]
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment