-
Notifications
You must be signed in to change notification settings - Fork 267
/
build.gradle
237 lines (218 loc) · 7.86 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryPlugin
import dependencies.Dep
import dependencies.Packages
import publish.DistributionTrack
import publish.EditStatus
import publish.PromoteApk
import publish.UploadApk
apply from: file('gradle/dependencyGraph.gradle')
buildscript {
ext {
isCi = System.getenv("CI") == "true"
isReleaseBuild = System.getenv("RELEASE_BUILD") == "true"
}
repositories {
google()
if (!isCi) {
maven {
url "https://maven-central-asia.storage-download.googleapis.com/repos/central/data/"
}
}
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
maven { url "https://dl.bintray.com/kotlin/ktor" }
maven { url "http://kotlin.bintray.com/kotlin-dev" }
maven { url "https://plugins.gradle.org/m2/" }
maven { url 'https://maven.fabric.io/public' }
maven { url "http://storage.googleapis.com/r8-releases/raw/master" }
}
dependencies {
classpath Dep.GradlePlugin.android
classpath Dep.GradlePlugin.kotlin
classpath Dep.GradlePlugin.kotlinSerialization
classpath Dep.GradlePlugin.playServices
classpath Dep.GradlePlugin.safeArgs
classpath Dep.GradlePlugin.jetifier
classpath Dep.GradlePlugin.licensesPlugin
classpath Dep.GradlePlugin.crashlytics
classpath Dep.GradlePlugin.iconRibbonPlugin
}
}
allprojects {
repositories {
google().content{
// Workaround for https://youtrack.jetbrains.com/issue/KT-28128
excludeGroup("Kotlin/Native")
}
if (!isCi) {
maven {
url "https://maven-central-asia.storage-download.googleapis.com/repos/central/data/"
content {
excludeGroup("Kotlin/Native")
}
}
}
jcenter() {
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url "https://kotlin.bintray.com/kotlinx"
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url 'https://dl.bintray.com/kotlin/kotlin-eap'
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url "http://kotlin.bintray.com/kotlin-dev"
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url "https://dl.bintray.com/kotlin/ktor"
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url "https://dl.bintray.com/soywiz/soywiz"
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url "https://jitpack.io"
content {
excludeGroup("Kotlin/Native")
}
}
}
tasks.matching { it instanceof Test }.all {
testLogging {
events = ["failed", "skipped"]
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
plugins.whenPluginAdded {
if (it instanceof AppPlugin || it instanceof LibraryPlugin) {
project.with {
configurations {
ktlint
}
dependencies {
ktlint "com.github.shyiko:ktlint:0.29.0"
}
task ktlint(type: JavaExec, group: "verification") {
def parameters = ["--android", '--editorconfig', "${rootProject.projectDir}/.editorconfig", "--reporter=checkstyle,output=${buildDir}/ktlint/checkstyle.xml"]
if (!isCi) {
parameters += "--reporter=html,artifact=me.cassiano:ktlint-html-reporter:0.2.0,output=${buildDir}/ktlint/checkstyle.html"
}
parameters += ['src/main/**/*.kt', 'src/debug/**/*.kt', 'src/release/**/*.kt', 'src/commonMain/**/*.kt', 'src/test/**/*.kt']
description = 'Check Kotlin code style.'
args = parameters
// https://github.com/shyiko/ktlint/blob/5fe8d0e203275a1a3337dc9777b50ec2a34a58df/ktlint/src/main/kotlin/com/github/shyiko/ktlint/Main.kt
main = 'com.github.shyiko.ktlint.Main'
classpath = configurations.ktlint
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Format Kotlin files based on code style."
classpath = configurations.ktlint
main = "com.github.shyiko.ktlint.Main"
args "--android", '-F', 'src/main/**/*.kt', 'src/debug/**/*.kt', 'src/release/**/*.kt', 'src/commonMain/**/*.kt', 'src/androidMain/**/*.kt', 'src/iOSMain/**/*.kt', 'src/test/**/*.kt'
}
task androidDependenciesExtra(dependsOn: 'androidDependencies') {
description 'Download extra dependencies for the CI Gradle Cache'
doLast {
// androidDependencies do not touch some configurations
configurations.findAll {
it.name.matches(/(ktlint|kapt|_internal_aapt2_binary|lintClassPath)/) && it.canBeResolved
}.files
}
}
}
}
}
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.android.tools.build.jetifier') {
details.useVersion '1.0.0-beta02'
}
}
}
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "300"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
task dependencyReport {
doLast {
def file = new File("project-dependencies.dot")
file.delete()
file << "digraph {\n"
file << "splines=ortho\n"
rootProject.childProjects.each { item ->
def from = item.value
from.configurations.compile.dependencies
.matching { it in ProjectDependency }
.each { to -> file << ("\"${from.name}\" -> \"${to.name}\"\n") }
}
file << "}\n"
}
}
task publishAlpha {
doLast {
def uploadApk = new UploadApk(logger)
def apkFile = new File(System.getenv("UNIVERSAL_APK_PATH"))
// FIXME more flexible
def mappingFile = new File(rootProject.projectDir, ".transart/mapping.txt")
uploadApk.execute(
Packages.name,
rootProject.file(".release/service-account.json"),
apkFile,
mappingFile,
DistributionTrack.Alpha.INSTANCE,
"New Alpha Release",
EditStatus.Completed.INSTANCE,
[
"en-US": rootProject.file("publish/release-notes/en-US/default.txt"),
"ja-JP": rootProject.file("publish/release-notes/ja-JP/default.txt")
]
)
}
}
task promoteProduction {
doLast {
def promoteApk = new PromoteApk(logger)
def editId = project.property("editId")
if (!editId) {
throw new GradleScriptException("editId must be privided")
}
promoteApk.execute(
Packages.name,
rootProject.file(".release/service-account.json"),
editId
)
}
}