forked from mozilla-mobile/fenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
240 lines (210 loc) · 7.57 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
238
239
240
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import org.mozilla.fenix.gradle.tasks.GithubDetailsTask
buildscript {
// This logic is duplicated in the allprojects block: I don't know how to fix that.
repositories {
maven {
name "Mozilla Nightly"
url "https://nightly.maven.mozilla.org/maven2"
content {
// Improve performance: only check moz maven for mozilla deps.
includeGroupByRegex RepoMatching.mozilla
}
}
maven {
name "Mozilla"
url "https://maven.mozilla.org/maven2"
content {
// Improve performance: only check moz maven for mozilla deps.
includeGroupByRegex RepoMatching.mozilla
}
}
if (project.hasProperty("googleRepo")) {
maven {
name "Google"
allowInsecureProtocol true // Local Nexus in CI uses HTTP
url project.property("googleRepo")
}
} else {
google() {
content {
// Improve performance: only check google maven for google deps.
includeGroupByRegex RepoMatching.androidx
includeGroupByRegex RepoMatching.comAndroid
includeGroupByRegex RepoMatching.comGoogle
}
}
}
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
mavenCentral() {
content {
// Improve security: don't search deps with known repos.
excludeGroupByRegex RepoMatching.mozilla
excludeGroupByRegex RepoMatching.androidx
excludeGroupByRegex RepoMatching.comAndroid
excludeGroupByRegex RepoMatching.comGoogle
}
}
}
}
dependencies {
classpath FenixDependencies.tools_androidgradle
classpath FenixDependencies.tools_kotlingradle
classpath FenixDependencies.tools_benchmarkgradle
classpath FenixDependencies.androidx_safeargs
classpath FenixDependencies.osslicenses_plugin
classpath "org.mozilla.components:tooling-glean-gradle:${FenixVersions.mozilla_android_components}"
classpath "org.mozilla.components:tooling-nimbus-gradle:${FenixVersions.mozilla_android_components}"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id("io.gitlab.arturbosch.detekt").version("1.19.0")
}
allprojects {
// This logic is duplicated in the buildscript block: I don't know how to fix that.
repositories {
maven {
name "Mozilla Nightly"
url "https://nightly.maven.mozilla.org/maven2"
content {
// Improve performance: only check moz maven for mozilla deps.
includeGroupByRegex RepoMatching.mozilla
}
}
maven {
name "Mozilla"
url "https://maven.mozilla.org/maven2"
content {
// Improve performance: only check moz maven for mozilla deps.
includeGroupByRegex RepoMatching.mozilla
}
}
if (project.hasProperty("googleRepo")) {
maven {
name "Google"
url project.property("googleRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
google() {
content {
// Improve performance: only check google maven for google deps.
includeGroupByRegex RepoMatching.androidx
includeGroupByRegex RepoMatching.comAndroid
includeGroupByRegex RepoMatching.comGoogle
}
}
}
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
mavenCentral() {
content {
// Improve security: don't search deps with known repos.
excludeGroupByRegex RepoMatching.mozilla
excludeGroupByRegex RepoMatching.androidx
excludeGroupByRegex RepoMatching.comAndroid
excludeGroupByRegex RepoMatching.comGoogle
}
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.allWarningsAsErrors = true
kotlinOptions.freeCompilerArgs += [
"-opt-in=kotlin.RequiresOptIn", "-Xjvm-default=all"
]
}
}
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
detekt {
input = files("$projectDir/app/src")
config = files("$projectDir/config/detekt.yml")
reports {
html {
enabled = true
destination = file("$projectDir/build/reports/detekt.html")
}
xml {
enabled = false
}
txt {
enabled = false
}
}
}
tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach() {
autoCorrect = true
exclude "**/test/**"
exclude "**/androidTest/**"
exclude "**/build/**"
exclude "**/resources/**"
exclude "**/tmp/**"
}
// Apply same path exclusions as for the main task
tasks.withType(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask).configureEach() {
exclude "**/test/**"
exclude "**/androidTest/**"
exclude "**/build/**"
exclude "**/resources/**"
exclude "**/tmp/**"
}
configurations {
ktlint
}
dependencies {
ktlint("com.pinterest:ktlint:0.47.0") {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
}
}
detekt project(":mozilla-detekt-rules")
detekt "io.gitlab.arturbosch.detekt:detekt-cli:${FenixVersions.detekt}"
}
tasks.register('ktlint', JavaExec) {
group = "verification"
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
}
tasks.withType(io.gitlab.arturbosch.detekt.Detekt.class).configureEach {
exclude("**/resources/**")
exclude("**/tmp/**")
}
tasks.register("listRepositories") {
doLast {
println "Repositories:"
project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
}
}
tasks.register("githubTestDetails", GithubDetailsTask) {
text = "### [Unit Test Results]({reportsUrl}/test/testDebugUnitTest/index.html)"
}
tasks.register("githubLintDetektDetails", GithubDetailsTask) {
text = "### [Detekt Results]({reportsUrl}/detekt.html)"
}
tasks.register("githubLintAndroidDetails", GithubDetailsTask) {
text = "### [Android Lint Results]({reportsUrl}/lint-results-debug.html)"
}