-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.gradle
110 lines (101 loc) · 3.14 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath "com.tencent.mm:AndResGuard-gradle-plugin:${andResGuardVersion}"
}
}
allprojects {
repositories {
//本地的Maven仓库:{USER_HOME}/.m2/repository,如C:/Users/Administrator/.m2/repository
mavenLocal()
//项目里的aar文件
flatDir { dirs "libs" }
//JitPack提供的Maven仓库
maven { url "https://jitpack.io" }
//JFrog公司提供的Maven仓库:https://jcenter.bintray.com
jcenter()
//谷歌公司提供的Maven仓库:https://maven.google.com
google()
//Sonatype公司提供的中央库:http://central.maven.org/maven2
mavenCentral()
}
}
subprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
//增加一些编译选项
//options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
task clean(type: Delete) {
println("********** clean build **********")
println("delete project dir:" + rootProject.buildDir)
rootProject.buildDir.deleteDir()
def dir = new File(new File(".").getAbsolutePath())
println(" root dir:" + dir.getAbsolutePath())
dir.eachDirRecurse {
dir2 ->
dir2.eachDirMatch(~/build/) {
directory ->
println("delete child dir:" + directory)
directory.deleteDir()
}
}
}
@SuppressWarnings(["GrMethodMayBeStatic", "unused"])
def gitGitCommitNumber() {
try {
// See https://www.jianshu.com/p/1f81af606e41
def cmd = 'git rev-list HEAD --first-parent --count'
return cmd.execute().text.trim().toInteger()
} catch (ignored) {
return 1
}
}
@SuppressWarnings(["GrMethodMayBeStatic", "unused"])
def getGitLatestTag() {
try {
// See https://www.jianshu.com/p/1f81af606e41
def cmd = 'git describe --tags'
return cmd.execute().text.trim()
} catch (ignored) {
return "1.0.0"
}
}
@SuppressWarnings(["GrMethodMayBeStatic", "unused"])
def getGitBranch() {
try {
// See https://www.jianshu.com/p/1f81af606e41
def cmd = 'git symbolic-ref --short -q HEAD'
return cmd.execute().text.trim()
} catch (ignored) {
return "unknown"
}
}
@SuppressWarnings(["GrMethodMayBeStatic", "unused"])
def getGitLatestCommitHash() {
try {
// See https://www.cnblogs.com/fuyaozhishang/p/7675551.html
def cmd = 'git rev-parse HEAD'
return cmd.execute().text.trim()
} catch (ignored) {
return "unknown"
}
}
@SuppressWarnings(["GrMethodMayBeStatic", "unused"])
def getGitLatestCommitHashShort() {
try {
// See https://www.jianshu.com/p/1f81af606e41
def cmd = 'git rev-parse --short HEAD'
return cmd.execute().text.trim()
} catch (ignored) {
return "unknown"
}
}