-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathutils.gradle
79 lines (71 loc) · 2.28 KB
/
utils.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
//get gradle.property or ext.property boolean value
def getBooleanPropertyIfExist(propertyString) {
if (hasProperty(propertyString)) {
if (project[propertyString].toBoolean()) {
return true
}
}
return false
}
//返回0,1,2三种数值,默认返回0
def getCompileType(propertyString) {
if (hasProperty(propertyString)) {
try {
def t = Integer.parseInt(project[propertyString])
if (t == 1 || t == 2) {
return t
}
} catch (Exception ignored) {
return 0
}
}
return 0
}
//根据property选择依赖方式,0采用project形式编译,1采用aar形式编译,2不编译
def runtimeOnlyByPropertyType(pro, modulePath, version = '1.0.0') {
def moduleName
if (modulePath.lastIndexOf(':') >= 0) {
moduleName = modulePath.substring(modulePath.indexOf(':') + 1, modulePath.length())
} else {
moduleName = modulePath
}
def type = getCompileType(moduleName+'CompileType')
if (type == 0) {
dependencies.runtimeOnly pro.project(":$modulePath")
} else if (type == 1) {
dependencies.runtimeOnly "com.rong360.example.modules:$moduleName:$version@aar"
}
}
//add task about publishing aar to local maven
task publishLocalMaven {
group = 'msm'
description = 'publish aar to local maven'
dependsOn project.path + ':clean'
finalizedBy 'uploadArchives'
doLast {
apply plugin: 'maven'
project.group = 'com.rong360.example.modules'
if (project.name == "module-a") {//may changer version
project.version = '1.0.0'
} else {
project.version = '1.0.0'
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri(project.rootProject.rootDir.path + '/local_maven'))
}
}
}
uploadArchives.doFirst {
println "START publish aar:" + project.name + " " + project.version
}
uploadArchives.doLast {
println "End publish aar:" + project.name + " " + project.version
}
}
}
ext {
getBooleanPropertyIfExist = this.&getBooleanPropertyIfExist
runtimeOnlyByPropertyType = this.&runtimeOnlyByPropertyType
}