-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-mix.gradle
121 lines (111 loc) · 3.58 KB
/
build-mix.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
// define the common method for android configuration
//
ext.findBuildTools = {
def localProperties = new File(projectDir, "local.properties")
String buildTools = "25.0.2";
if (localProperties.exists()) {
def properties = new Properties()
localProperties.withInputStream {
instr->properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
def buildToolsDir = new File(sdkDir, "build-tools")
if (buildToolsDir.exists()) {
def tools = buildToolsDir.list()
if (tools != null) {
Arrays.sort(tools)
buildTools = tools[tools.length - 1]
}
}
}
logForfind("findBuildTools:" + buildTools)
return buildTools
}
ext.findCompileSdkVersion = {
int cimpileSdkVersion = 19
def projProp = new File(projectDir, "project.properties")
if (projProp.exists()) {
def properties = new Properties()
projProp.withInputStream {
instr->properties.load(instr)
}
def target = properties.getProperty('target').trim()
def pref = "android-"
if (target != null && target.startsWith(pref)) {
cimpileSdkVersion = Integer.parseInt(target.substring(pref.length()))
}
}
logForfind("findCompileSdkVersion:" + cimpileSdkVersion);
return cimpileSdkVersion;
}
ext.findProguardFile = {
def file = new File(projectDir, "proguard-project.txt")
def proguardFile
if (null != file && file.isFile()) {
proguardFile = file.getAbsolutePath()
} else {
proguardFile = null
}
logForfind("findProguardFile:" + proguardFile);
return proguardFile;
}
ext.findTargetSdk = {
int targetSdk = 8;
def manifest = findManifest()
String temp = manifest.getAt("uses-sdk").getProperty('@android:targetSdkVersion').toString();
if (null != temp && temp.length() > 0) {
targetSdk = Integer.parseInt(temp);
}
logForfind("findTargetSdk:" + targetSdk)
return targetSdk;
}
ext.findMinSdk = {
int minSdk = 8;
def manifest = findManifest()
String temp = manifest.getAt("uses-sdk").getProperty('@android:minSdkVersion').toString();
if (null != temp && temp.length() > 0) {
minSdk = Integer.parseInt(temp);
}
logForfind("findMinSdk:" + minSdk)
return minSdk
}
ext.findVersionName = {
def manifest = findManifest();
String versionName = manifest.getProperty('@android:versionName')
logForfind("findVersionName:" + versionName)
return versionName
}
ext.findVersionCode = {
def manifest = findManifest();
String temp = manifest.getProperty('@android:versionCode');
def versionCode = Integer.parseInt(temp)
logForfind("findVersionCode:" + versionCode)
return versionCode
}
ext.findApplicationId = {
def manifest = findManifest();
String pkg = manifest.getProperty('@package');
logForfind("findApplicationId:" + pkg)
return pkg;
}
ext.findManifest = {
def file = new File(projectDir, "AndroidManifest.xml")
def xml = new XmlSlurper()
def manifest = xml.parse(file)
return manifest;
}
ext.findJarByPrefix = { prefix ->
def libs = new File(projectDir, "libs")
String ret = null
for (String file : libs.list()) {
if (file.startsWith(prefix)) {
ret = file;
break
}
}
logForfind("findJarByPrefix: " + ret + ", prefix: " + prefix)
return ret;
}
ext.logForfind = { msg ->
println("ext.find:" + msg)
}