-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathbuild.gradle
executable file
·150 lines (131 loc) · 6.29 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* Copyright (C) 2017-2018 Manbang Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'com.android.application'
apply plugin: 'com.wlqq.phantom.plugin'
android {
compileSdkVersion androidVersion.compileSdk
buildToolsVersion androidVersion.buildTools
defaultConfig {
applicationId "com.wlqq.phantom.plugin.component"
minSdkVersion androidVersion.minSdk
targetSdkVersion androidVersion.targetSdk
versionCode 10000
versionName "1.0.0"
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile 'proguard-phantom.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile 'proguard-phantom.pro'
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "${variant.applicationId}_${variant.versionName}.apk"
}
}
}
dependencies {
compileOnly "com.wlqq.phantom:phantom-communication-lib:${phantomVersion.communicationLib}"
compileOnly "com.wlqq.phantom:phantom-plugin-lib:${phantomVersion.pluginLib}"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:support-v4:${androidVersion.supportLib}"
implementation 'io.github.shaobin0604:awesomelog:1.0.1'
testImplementation "junit:junit:${testVersion.junit}"
}
def deletePluginInHost() {
println "deletePluginInHost..."
def assetsDir = file(project(':phantom-sample:host').getProjectDir().absolutePath + '/src/main/assets/plugins')
if (!assetsDir.exists()) {
assetsDir.mkdirs()
}
assetsDir.eachFile { file ->
println "list assets file: " + file.name
if (file.name.startsWith(android.defaultConfig.applicationId)) {
def ret = file.delete()
println "delete assets file: ${file.name}, result: ${ret}"
}
}
}
def copyPluginToHost(String dir) {
println "copy build plugin to app assets..."
copy {
from(buildDir.absolutePath + '/outputs/apk/' + dir) {
include('*.apk')
}
into(project(':phantom-sample:host').getProjectDir().absolutePath + '/src/main/assets/plugins/')
}
}
afterEvaluate { project ->
project.tasks.assembleDebug.doLast {
deletePluginInHost()
copyPluginToHost('debug')
}
project.tasks.assembleRelease.doLast {
deletePluginInHost()
copyPluginToHost('release')
}
}
phantomPluginConfig {
/*------------------------------ 剔除 support-v4 及其依赖的库 BEGIN ----------------------------*/
excludeLib "com.android.support:support-v4:${androidVersion.supportLib}"
excludeLib "com.android.support:support-core-ui:${androidVersion.supportLib}"
excludeLib "com.android.support:support-compat:${androidVersion.supportLib}"
excludeLib "com.android.support:support-media-compat:${androidVersion.supportLib}"
excludeLib "com.android.support:support-core-utils:${androidVersion.supportLib}"
excludeLib "com.android.support:support-fragment:${androidVersion.supportLib}"
excludeLib "com.android.support:support-annotations:${androidVersion.supportLib}"
excludeLib "com.android.support:cursoradapter:${androidVersion.supportLib}"
excludeLib "com.android.support:interpolator:${androidVersion.supportLib}"
excludeLib "com.android.support:versionedparcelable:${androidVersion.supportLib}"
excludeLib "com.android.support:documentfile:${androidVersion.supportLib}"
excludeLib "com.android.support:customview:${androidVersion.supportLib}"
excludeLib "com.android.support:slidingpanelayout:${androidVersion.supportLib}"
excludeLib "com.android.support:swiperefreshlayout:${androidVersion.supportLib}"
excludeLib "com.android.support:drawerlayout:${androidVersion.supportLib}"
excludeLib "com.android.support:coordinatorlayout:${androidVersion.supportLib}"
excludeLib "com.android.support:loader:${androidVersion.supportLib}"
excludeLib "com.android.support:viewpager:${androidVersion.supportLib}"
excludeLib "com.android.support:collections:${androidVersion.supportLib}"
excludeLib "com.android.support:asynclayoutinflater:${androidVersion.supportLib}"
excludeLib "com.android.support:print:${androidVersion.supportLib}"
excludeLib "com.android.support:localbroadcastmanager:${androidVersion.supportLib}"
excludeLib "android.arch.lifecycle:viewmodel:${androidVersion.archLib}"
excludeLib "android.arch.lifecycle:runtime:${androidVersion.archLib}"
excludeLib "android.arch.lifecycle:common:${androidVersion.archLib}"
excludeLib "android.arch.lifecycle:livedata:${androidVersion.archLib}"
excludeLib "android.arch.lifecycle:livedata-core:${androidVersion.archLib}"
excludeLib "android.arch.core:common:${androidVersion.archLib}"
/*------------------------------ 删除 support-v4 及其依赖的库 END ----------------------------*/
/*------------------------------ 混淆配置 BEGIN ------------------------------*/
libraryJarsProguardFile file('proguard-phantom.pro')
/*------------------------------ 混淆配置 END ------------------------------*/
/*------------------------------ 快速安装插件配置 BEGIN ------------------------*/
// 宿主包名
hostApplicationId = "com.wlqq.phantom.sample"
// 宿主 launcher Activity full class name
hostAppLauncherActivity = "com.wlqq.phantom.sample.MainActivity"
// 插件包名
pluginApplicationId = android.defaultConfig.applicationId
// 插件版本名
pluginVersionName = android.defaultConfig.versionName
/*------------------------------ 快速安装插件配置 END -------------------------*/
}