-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
91 lines (70 loc) · 2.87 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.klint_version = '11.3.1'
ext.androidx_hilt_version = '1.2.0'
ext.hilt_version = '2.52'
ext.kotlin_version = '1.8.0'
ext.tinylog_version = '2.7.0'
repositories {
google()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.6.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'com.google.dagger.hilt.android' version "$hilt_version" apply false
id 'org.jlleitschuh.gradle.ktlint' version "$klint_version"
id 'org.jlleitschuh.gradle.ktlint-idea' version "$klint_version"
}
allprojects {
repositories {
google()
mavenCentral()
}
}
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'
}
}