-
Notifications
You must be signed in to change notification settings - Fork 98
/
build.gradle
184 lines (166 loc) · 5.96 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
buildscript {
ext.keystore = (project.hasProperty('androidKeystore') ?
project.property('androidKeystore') : '/fake/path/to/keystore')
ext.keystorePassword = (project.hasProperty('androidKeystorePassword') ?
project.property('androidKeystorePassword') : 'fakepassword')
ext.releaseKeyAlias = (project.hasProperty('androidReleaseKeyAlias') ?
project.property('androidReleaseKeyAlias') : 'fakealias')
ext.releaseKeyPassword = (project.hasProperty('androidReleaseKeyPassword') ?
project.property('androidReleaseKeyPassword') : 'fakepassword')
ext.firebaseAppId = (project.hasProperty('firebaseAppId') ?
project.property('firebaseAppId') : 'fakeappid')
ext.getPropertyValue = { propertyKey ->
def property = System.getenv(propertyKey)
if (property == null) {
logger.log(LogLevel.INFO, "Could not locate $propertyKey as environment variable. " +
"Trying local.properties")
Properties properties = new Properties()
if (project.rootProject.file('local.properties').exists()) {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
property = properties.getProperty(propertyKey)
}
}
if (property == null) {
logger.log(LogLevel.WARN, "$propertyKey unavailable.")
}
return property
}
repositories {
google()
mavenCentral()
maven {
url "https://twilio.jfrog.io/artifactory/internal-releases"
credentials {
username "${getPropertyValue('ARTIFACTORY_USERNAME')}"
password "${getPropertyValue('ARTIFACTORY_PASSWORD')}"
}
metadataSources {
mavenPom()
artifact()
}
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.3.1'
classpath "com.google.gms:google-services:4.4.2"
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.2'
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.1'
classpath 'com.google.firebase:firebase-appdistribution-gradle:5.0.0'
}
}
plugins {
id "com.diffplug.spotless" version '6.19.0'
}
apply plugin: "com.diffplug.spotless"
spotless {
format 'misc', {
target '**/*.gradle', '**/*.md', '**/.gitignore'
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
java {
target '**/*.java'
googleJavaFormat().aosp()
}
kotlin {
target '**/*.kt'
ktlint()
}
}
task incrementVersionCode {
description = 'Increment the version code'
group = 'Git'
doLast {
def githubToken = System.getenv("GITHUB_TOKEN")
def repoSlug = "${System.env.CIRCLE_PROJECT_USERNAME}/${System.env.CIRCLE_PROJECT_REPONAME}"
def gitRef = "https://${githubToken}@github.com/${repoSlug}.git"
def remote = "upstream"
def pushNullFile = new FileOutputStream("/dev/null")
def versionCode = project.property("versionCode")
def versionCodeTag = "v0.$versionCode"
def newVersionCode = (versionCode as Integer) + 1
// Create build directory if not created
if (!getLayout().getBuildDirectory().asFile.get().exists()) {
getLayout().getBuildDirectory().asFile.get().mkdir()
}
exec {
workingDir "${rootDir}"
commandLine "git", "remote", "add", "${remote}", "${gitRef}"
// Ignore exit value because remote may have been added in previous task
ignoreExitValue true
}
exec {
workingDir "${rootDir}"
commandLine "git", "fetch", "${remote}"
}
exec {
workingDir "${rootDir}"
commandLine "git", "tag", "-a", "$versionCodeTag", "-m", "$versionCodeTag"
}
exec {
workingDir "${rootDir}"
commandLine "sed",
"s@versionCode=.*@versionCode=${newVersionCode}@",
"gradle.properties"
standardOutput new FileOutputStream("${buildDir}/gradle.properties")
}
exec {
workingDir "${rootDir}"
commandLine "mv", "${buildDir}/gradle.properties", "gradle.properties"
}
exec {
workingDir "${rootDir}"
commandLine "echo", "New version code:"
}
exec {
workingDir "${rootDir}"
commandLine "cat", "gradle.properties"
}
exec {
workingDir "${rootDir}"
commandLine "git", "add", "gradle.properties"
}
exec {
workingDir "${rootDir}"
commandLine "git", "commit", "gradle.properties", "-m", "Bump version code [skip ci]"
}
exec {
workingDir "${rootDir}"
commandLine "git", "push", "--quiet", "${remote}", "${System.env.CIRCLE_BRANCH}"
standardOutput pushNullFile
}
exec {
workingDir "${rootDir}"
commandLine "git", "push", "--quiet", "${remote}", "$versionCodeTag"
standardOutput pushNullFile
}
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://oss.jfrog.org/artifactory/libs-snapshot/'
}
maven {
url "https://twilio.jfrog.io/artifactory/internal-releases"
credentials {
username "${getPropertyValue('ARTIFACTORY_USERNAME')}"
password "${getPropertyValue('ARTIFACTORY_PASSWORD')}"
}
metadataSources {
mavenPom()
artifact()
}
}
maven {
url 'https://jitpack.io'
}
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
}
}