-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
67 lines (49 loc) · 2.41 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.dagger.hilt.android) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.kapt) apply false
// TODO: Dagger’s KSP support is currently in alpha, see: https://dagger.dev/dev-guide/ksp
// alias(libs.plugins.ksp) apply false
}
tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}
private File loadVersionPropertiesFile(String moduleName) {
def versionPropsFile = file("$moduleName/version.properties")
println "reading '${versionPropsFile.name}' for module '$moduleName' ..."
if (!versionPropsFile.exists()) {
versionPropsFile.createNewFile()
}
return versionPropsFile
}
@SuppressWarnings("unused")
int updateVersionCode(moduleName) {
File propertiesFile = loadVersionPropertiesFile(moduleName)
Properties versionProperties = new Properties()
versionProperties.load(new FileInputStream(propertiesFile))
int versionCode = Integer.parseInt(versionProperties.getProperty('VERSION_CODE', '0').toString()).intValue() + 1
versionProperties['VERSION_CODE'] = versionCode.toString()
versionProperties.store(propertiesFile.newWriter(), null)
println "version code: $versionCode"
return versionCode
}
@SuppressWarnings("unused")
def readKeystoreProperties(moduleName) {
def propertiesFile = rootProject.file('keystore.properties')
def configName = 'release'
println "reading '${propertiesFile.absolutePath}' for module '$moduleName' ..."
Project moduleProject = project.project(moduleName)
if (propertiesFile.exists() && moduleProject.hasProperty("android") && moduleProject.android.signingConfigs.hasProperty(configName)) {
def props = new Properties()
props.load(new FileInputStream(propertiesFile))
moduleProject.android.signingConfigs[configName].storeFile = file(props['STORE_FILE'])
moduleProject.android.signingConfigs[configName].storePassword = props['STORE_PASSWORD']
moduleProject.android.signingConfigs[configName].keyAlias = props['KEY_ALIAS']
moduleProject.android.signingConfigs[configName].keyPassword = props['KEY_PASSWORD']
println 'done'
}
}