-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.gradle
90 lines (77 loc) · 3.21 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
buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
apply from: 'config/dependencies.gradle'
apply from: 'config/dependencies.gradle', to: it
apply from: "$rootDir/config/git-hooks.gradle.kts"
classpath "com.android.tools.build:gradle:$it.gradle.gradle"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$it.compiler.kotlin"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$it.version.navigation"
classpath "com.diffplug.spotless:spotless-plugin-gradle:$it.version.spotless"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$version.detekt"
classpath "com.github.ben-manes:gradle-versions-plugin:$version.gradleVersions"
classpath "com.google.dagger:hilt-android-gradle-plugin:$version.hilt"
}
}
allprojects {
repositories {
google()
maven { url "https://jitpack.io" }
mavenCentral()
}
afterEvaluate { project ->
def buildRelease = 'release'
def isReleaseBuild = getCurrentVariant() == buildRelease
if (isReleaseBuild &&
project.hasProperty("android") &&
android.signingConfigs.hasProperty(buildRelease)) {
try {
def propsFile = rootProject.file('keystore.properties')
def props = new Properties()
props.load(new FileInputStream(propsFile))
android.signingConfigs[buildRelease].storeFile = file(props['RELEASE.STORE_FILE'])
android.signingConfigs[buildRelease].storePassword = props['RELEASE.STORE_PASSWORD']
android.signingConfigs[buildRelease].keyAlias = props['RELEASE.KEY_ALIAS']
android.signingConfigs[buildRelease].keyPassword = props['RELEASE.KEY_PASSWORD']
} catch (ignored) {
throw new InvalidUserDataException(
"You should define\n" +
"'RELEASE.STORE_FILE', \n" +
"'RELEASE.STORE_PASSWORD', \n" +
"'RELEASE.KEY_ALIAS\n" +
"'and " +
"'RELEASE.KEY_PASSWORD'" +
" in keystore.properties. *Rename and update keystore.properties.sample if exists.")
}
}
}
}
def buildAliases = [
'reformat': ['ktlintFormat', 'spotlessApply'],
]
def expandedTaskList = []
gradle.startParameter.taskNames.each {
expandedTaskList << (buildAliases[it] ? buildAliases[it] : it)
}
gradle.startParameter.taskNames = expandedTaskList.flatten()
import java.util.regex.Matcher
import java.util.regex.Pattern
def getCurrentVariant() {
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString()
Pattern pattern
if (tskReqStr.contains("assemble"))
pattern = Pattern.compile("assemble(\\w+)(Release|Debug)")
else
pattern = Pattern.compile("generate(\\w+)(Release|Debug)")
Matcher matcher = pattern.matcher(tskReqStr)
if (matcher.find()) {
return matcher.group(2).toLowerCase()
} else {
return ""
}
}