-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
96 lines (80 loc) · 2.54 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
import ru.chernakov.rocketscienceapp.Plugins
import ru.chernakov.rocketscienceapp.AndroidConfig
apply plugin: Plugins.dependenciesVersions
ext {
projectName = AndroidConfig.NAME
versionName = gitVersionName
versionCode = gitVersionCode
versionHash = gitRefHash
}
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath Plugins.ClassPaths.gradle
classpath Plugins.ClassPaths.kotlin
classpath Plugins.ClassPaths.googleServices
classpath Plugins.ClassPaths.timeTracker
classpath Plugins.ClassPaths.detekt
classpath Plugins.ClassPaths.dependenciesVersions
classpath Plugins.ClassPaths.navigationSafeArgs
classpath Plugins.ClassPaths.firebaseCrashlytics
classpath Plugins.ClassPaths.firebaseAppDistribution
}
}
allprojects {
repositories {
google()
jcenter()
}
}
subprojects {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
// Enable experimental coroutines APIs, including Flow
freeCompilerArgs += "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"
freeCompilerArgs += "-Xuse-experimental=kotlinx.coroutines.FlowPreview"
// Set JVM target to 1.8
jvmTarget = "1.8"
}
}
}
dependencyUpdates {
checkForGradleUpdate = true
outputFormatter = "plain"
outputDir = "build/dependencies"
reportfileName = "report"
}
task clean(type: Delete) {
delete rootProject.buildDir
}
static def getGitVersionName() {
def tag = 'git describe --tags'.execute().text.split('-').first()?.trim()
if (tag =~ /^v.*$/ || tag =~ /^d.*$/) {
return tag.substring(1)
}
return '1.0.0'
}
static def getGitRefHash() {
return 'git rev-parse HEAD'.execute().text.substring(0, 8)
}
int getGitVersionCode() {
return (int) (((new Date().getTime() / 1000) - 1451606400) / 10)
}
def getProps(String fileName, String propName) {
return getProps(fileName, propName, "\"define config field: " + propName + "\"")
}
def getProps(String fileName, String propName, String defaultValue) {
def propsFile = rootProject.file(fileName)
if (propsFile.exists()) {
def props = new Properties()
props.load(new FileInputStream(propsFile))
return props[propName] != null ? props[propName] : defaultValue
} else {
return "\"define config file " + fileName + "\""
}
}