Bug 1842694 - Refactor GithubDetailsTask into a plugin using composite build
[gecko.git] / mobile / android / fenix / build.gradle
blob4a0b37a799b396ef5b519bb68140b0fe0d431f82
1 // Top-level build file where you can add configuration options common to all sub-projects/modules.
3 buildscript {
4     // This logic is duplicated in the allprojects block: I don't know how to fix that.
5     repositories {
6         maven {
7             name "Mozilla Nightly"
8             url "https://nightly.maven.mozilla.org/maven2"
9             content {
10                 // Improve performance: only check moz maven for mozilla deps.
11                 includeGroupByRegex RepoMatching.mozilla
12             }
13         }
15         maven {
16             name "Mozilla"
17             url "https://maven.mozilla.org/maven2"
18             content {
19                 // Improve performance: only check moz maven for mozilla deps.
20                 includeGroupByRegex RepoMatching.mozilla
21             }
22         }
24         if (ExtraRepositories.mozillaStaging) {
25             maven {
26                 name "Mozilla Staging"
27                 url "https://maven-default.stage.mozaws.net/maven2"
28                 content {
29                     // Improve performance: only check moz maven for mozilla deps.
30                     includeGroupByRegex RepoMatching.mozilla
31                 }
32             }
33         }
35         if (project.hasProperty("googleRepo")) {
36             maven {
37                 name "Google"
38                 allowInsecureProtocol true // Local Nexus in CI uses HTTP
39                 url project.property("googleRepo")
40             }
41         } else {
42             google() {
43                 content {
44                     // Improve performance: only check google maven for google deps.
45                     includeGroupByRegex RepoMatching.androidx
46                     includeGroupByRegex RepoMatching.comAndroid
47                     includeGroupByRegex RepoMatching.comGoogle
48                 }
49             }
50         }
52         if (project.hasProperty("centralRepo")) {
53             maven {
54                 name "MavenCentral"
55                 url project.property("centralRepo")
56                 allowInsecureProtocol true // Local Nexus in CI uses HTTP
57             }
58         } else {
59             mavenCentral() {
60                 content {
61                     // Improve security: don't search deps with known repos.
62                     excludeGroupByRegex RepoMatching.mozilla
63                     excludeGroupByRegex RepoMatching.androidx
64                     excludeGroupByRegex RepoMatching.comAndroid
65                 }
66             }
67         }
68     }
70     dependencies {
71         classpath ComponentsDependencies.tools_androidgradle
72         classpath ComponentsDependencies.tools_kotlingradle
73         classpath FenixDependencies.tools_benchmarkgradle
74         classpath FenixDependencies.androidx_safeargs
75         classpath FenixDependencies.osslicenses_plugin
76         classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
77         classpath "${ApplicationServicesConfig.groupId}:tooling-nimbus-gradle:${ApplicationServicesConfig.version}"
79         // NOTE: Do not place your application dependencies here; they belong
80         // in the individual module build.gradle files
81     }
83     // Variables in plugins {} aren't directly supported. Hack around it by setting an
84     // intermediate variable which can pull from FenixDependenciesPlugin.kt and be used later.
85     ext {
86         detekt_plugin = Versions.detekt
87         protobuf_plugin = FenixVersions.protobuf_plugin
88         python_envs_plugin = Versions.python_envs_plugin
89     }
92 plugins {
93     id("io.gitlab.arturbosch.detekt").version("$detekt_plugin")
96 allprojects {
97     // This logic is duplicated in the buildscript block: I don't know how to fix that.
98     repositories {
99         maven {
100             name "Mozilla Nightly"
101             url "https://nightly.maven.mozilla.org/maven2"
102             content {
103                 // Improve performance: only check moz maven for mozilla deps.
104                 includeGroupByRegex RepoMatching.mozilla
105             }
106         }
108         maven {
109             name "Mozilla"
110             url "https://maven.mozilla.org/maven2"
111             content {
112                 // Improve performance: only check moz maven for mozilla deps.
113                 includeGroupByRegex RepoMatching.mozilla
114             }
115         }
117         if (ExtraRepositories.mozillaStaging) {
118             maven {
119                 name "Mozilla Staging"
120                 url "https://maven-default.stage.mozaws.net/maven2"
121                 content {
122                     // Improve performance: only check moz maven for mozilla deps.
123                     includeGroupByRegex RepoMatching.mozilla
124                 }
125             }
126         }
128         if (project.hasProperty("googleRepo")) {
129             maven {
130                 name "Google"
131                 url project.property("googleRepo")
132                 allowInsecureProtocol true // Local Nexus in CI uses HTTP
133             }
134         } else {
135             google() {
136                 content {
137                     // Improve performance: only check google maven for google deps.
138                     includeGroupByRegex RepoMatching.androidx
139                     includeGroupByRegex RepoMatching.comAndroid
140                     includeGroupByRegex RepoMatching.comGoogle
141                 }
142             }
143         }
145         if (project.hasProperty("centralRepo")) {
146             maven {
147                 name "MavenCentral"
148                 url project.property("centralRepo")
149                 allowInsecureProtocol true // Local Nexus in CI uses HTTP
150             }
151         } else {
152             mavenCentral() {
153                 content {
154                     // Improve security: don't search deps with known repos.
155                     excludeGroupByRegex RepoMatching.mozilla
156                     excludeGroupByRegex RepoMatching.androidx
157                     excludeGroupByRegex RepoMatching.comAndroid
158                 }
159             }
160         }
161     }
163     tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
164         kotlinOptions.jvmTarget = "17"
165         kotlinOptions.allWarningsAsErrors = true
166         kotlinOptions.freeCompilerArgs += [
167             "-opt-in=kotlin.RequiresOptIn", "-Xjvm-default=all"
168         ]
169     }
172 tasks.register('clean', Delete) {
173     delete rootProject.buildDir
176 detekt {
177     input = files("$projectDir/app/src")
178     config = files("$projectDir/config/detekt.yml")
180     reports {
181         html {
182             enabled = true
183             destination = file("$projectDir/build/reports/detekt.html")
184         }
185         xml {
186             enabled = false
187         }
188         txt {
189             enabled = false
190         }
191     }
194 tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach() {
195     autoCorrect = true
197     exclude "**/test/**"
198     exclude "**/androidTest/**"
199     exclude "**/build/**"
200     exclude "**/resources/**"
201     exclude "**/tmp/**"
204 // Apply same path exclusions as for the main task
205 tasks.withType(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask).configureEach() {
206     exclude "**/test/**"
207     exclude "**/androidTest/**"
208     exclude "**/build/**"
209     exclude "**/resources/**"
210     exclude "**/tmp/**"
213 configurations {
214     ktlint
217 dependencies {
218     ktlint("com.pinterest:ktlint:${Versions.ktlint}") {
219         attributes {
220             attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
221         }
222     }
224     detekt project(":mozilla-detekt-rules")
225     detekt "io.gitlab.arturbosch.detekt:detekt-cli:${Versions.detekt}"
228 tasks.register('ktlint', JavaExec) {
229     group = "verification"
230     description = "Check Kotlin code style."
231     classpath = configurations.ktlint
232     main = "com.pinterest.ktlint.Main"
233     args "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
236 task ktlintFormat(type: JavaExec, group: "formatting") {
237     description = "Fix Kotlin code style deviations."
238     classpath = configurations.ktlint
239     mainClass.set("com.pinterest.ktlint.Main")
240     args "-F", "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
241     jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
244 tasks.withType(io.gitlab.arturbosch.detekt.Detekt.class).configureEach {
245     exclude("**/resources/**")
246     exclude("**/tmp/**")
249 tasks.register("listRepositories") {
250     doLast {
251         println "Repositories:"
252         project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
253     }
256 tasks.register("githubTestDetails", GithubDetailsTask) {
257     text = "### [Unit Test Results Fenix]({reportsUrl}/test/testFenixDebugUnitTest/index.html)"
260 tasks.register("githubLintDetektDetails", GithubDetailsTask) {
261     text = "### [Detekt Results Fenix]({reportsUrl}/detekt.html)"
264 tasks.register("githubLintAndroidDetails", GithubDetailsTask) {
265     text = "### [Android Lint Results Fenix]({reportsUrl}/lint-results-debug.html)"