Bug 1805683 - upstream Nimbus Messaging from Fenix to Android Components
[gecko.git] / mobile / android / fenix / build.gradle
blob2119cc42f4b43c3efa9733fa6ce53f6d4300609e
1 // Top-level build file where you can add configuration options common to all sub-projects/modules.
3 import org.mozilla.fenix.gradle.tasks.GithubDetailsTask
5 buildscript {
6     // This logic is duplicated in the allprojects block: I don't know how to fix that.
7     repositories {
8         maven {
9             name "Mozilla Nightly"
10             url "https://nightly.maven.mozilla.org/maven2"
11             content {
12                 // Improve performance: only check moz maven for mozilla deps.
13                 includeGroupByRegex RepoMatching.mozilla
14             }
15         }
17         maven {
18             name "Mozilla"
19             url "https://maven.mozilla.org/maven2"
20             content {
21                 // Improve performance: only check moz maven for mozilla deps.
22                 includeGroupByRegex RepoMatching.mozilla
23             }
24         }
26         if (project.hasProperty("googleRepo")) {
27             maven {
28                 name "Google"
29                 allowInsecureProtocol true // Local Nexus in CI uses HTTP
30                 url project.property("googleRepo")
31             }
32         } else {
33             google() {
34                 content {
35                     // Improve performance: only check google maven for google deps.
36                     includeGroupByRegex RepoMatching.androidx
37                     includeGroupByRegex RepoMatching.comAndroid
38                     includeGroupByRegex RepoMatching.comGoogle
39                 }
40             }
41         }
43         if (project.hasProperty("centralRepo")) {
44             maven {
45                 name "MavenCentral"
46                 url project.property("centralRepo")
47                 allowInsecureProtocol true // Local Nexus in CI uses HTTP
48             }
49         } else {
50             mavenCentral() {
51                 content {
52                     // Improve security: don't search deps with known repos.
53                     excludeGroupByRegex RepoMatching.mozilla
54                     excludeGroupByRegex RepoMatching.androidx
55                     excludeGroupByRegex RepoMatching.comAndroid
56                 }
57             }
58         }
59     }
61     dependencies {
62         classpath "org.mozilla.appservices:tooling-nimbus-gradle:${Versions.mozilla_appservices}"
64         classpath FenixDependencies.tools_androidgradle
65         classpath FenixDependencies.tools_kotlingradle
66         classpath FenixDependencies.tools_benchmarkgradle
67         classpath FenixDependencies.androidx_safeargs
68         classpath FenixDependencies.osslicenses_plugin
69         classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
70         classpath "org.mozilla.appservices:tooling-nimbus-gradle:${Versions.mozilla_appservices}"
72         // NOTE: Do not place your application dependencies here; they belong
73         // in the individual module build.gradle files
74     }
77 plugins {
78     id("io.gitlab.arturbosch.detekt").version("1.19.0")
81 allprojects {
82     // This logic is duplicated in the buildscript block: I don't know how to fix that.
83     repositories {
84         maven {
85             name "Mozilla Nightly"
86             url "https://nightly.maven.mozilla.org/maven2"
87             content {
88                 // Improve performance: only check moz maven for mozilla deps.
89                 includeGroupByRegex RepoMatching.mozilla
90             }
91         }
93         maven {
94             name "Mozilla"
95             url "https://maven.mozilla.org/maven2"
96             content {
97                 // Improve performance: only check moz maven for mozilla deps.
98                 includeGroupByRegex RepoMatching.mozilla
99             }
100         }
102         if (project.hasProperty("googleRepo")) {
103             maven {
104                 name "Google"
105                 url project.property("googleRepo")
106                 allowInsecureProtocol true // Local Nexus in CI uses HTTP
107             }
108         } else {
109             google() {
110                 content {
111                     // Improve performance: only check google maven for google deps.
112                     includeGroupByRegex RepoMatching.androidx
113                     includeGroupByRegex RepoMatching.comAndroid
114                     includeGroupByRegex RepoMatching.comGoogle
115                 }
116             }
117         }
119         if (project.hasProperty("centralRepo")) {
120             maven {
121                 name "MavenCentral"
122                 url project.property("centralRepo")
123                 allowInsecureProtocol true // Local Nexus in CI uses HTTP
124             }
125         } else {
126             mavenCentral() {
127                 content {
128                     // Improve security: don't search deps with known repos.
129                     excludeGroupByRegex RepoMatching.mozilla
130                     excludeGroupByRegex RepoMatching.androidx
131                     excludeGroupByRegex RepoMatching.comAndroid
132                 }
133             }
134         }
135     }
137     tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
138         kotlinOptions.jvmTarget = "11"
139         kotlinOptions.allWarningsAsErrors = true
140         kotlinOptions.freeCompilerArgs += [
141             "-opt-in=kotlin.RequiresOptIn", "-Xjvm-default=all"
142         ]
143     }
146 subprojects {
147     // Define a reusable task for updating the version in manifest.json for modules that package
148     // a web extension. We automate this to make sure we never forget to update the version, either
149     // in local development or for releases. In both cases, we want to make sure the latest version
150     // of all extensions (including their latest changes) are installed on first start-up.
151     ext.updateExtensionVersion = { task, extDir ->
152         configure(task) {
153             from extDir
154             include 'manifest.template.json'
155             rename { 'manifest.json' }
156             into extDir
158             def values = ['version': rootProject.ext.config.componentsVersion.split("a|b")[0] + "." + new Date().format('MMddHHmmss')]
159             inputs.properties(values)
160             expand(values)
161         }
162     }
165 tasks.register('clean', Delete) {
166     delete rootProject.buildDir
169 detekt {
170     input = files("$projectDir/app/src")
171     config = files("$projectDir/config/detekt.yml")
173     reports {
174         html {
175             enabled = true
176             destination = file("$projectDir/build/reports/detekt.html")
177         }
178         xml {
179             enabled = false
180         }
181         txt {
182             enabled = false
183         }
184     }
187 tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach() {
188     autoCorrect = true
190     exclude "**/test/**"
191     exclude "**/androidTest/**"
192     exclude "**/build/**"
193     exclude "**/resources/**"
194     exclude "**/tmp/**"
197 // Apply same path exclusions as for the main task
198 tasks.withType(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask).configureEach() {
199     exclude "**/test/**"
200     exclude "**/androidTest/**"
201     exclude "**/build/**"
202     exclude "**/resources/**"
203     exclude "**/tmp/**"
206 configurations {
207     ktlint
210 dependencies {
211     ktlint("com.pinterest:ktlint:0.48.2") {
212         attributes {
213             attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
214         }
215     }
217     detekt project(":mozilla-detekt-rules")
218     detekt "io.gitlab.arturbosch.detekt:detekt-cli:${FenixVersions.detekt}"
221 tasks.register('ktlint', JavaExec) {
222     group = "verification"
223     description = "Check Kotlin code style."
224     classpath = configurations.ktlint
225     main = "com.pinterest.ktlint.Main"
226     args "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
229 task ktlintFormat(type: JavaExec, group: "formatting") {
230     description = "Fix Kotlin code style deviations."
231     classpath = configurations.ktlint
232     mainClass.set("com.pinterest.ktlint.Main")
233     args "-F", "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
236 tasks.withType(io.gitlab.arturbosch.detekt.Detekt.class).configureEach {
237     exclude("**/resources/**")
238     exclude("**/tmp/**")
241 tasks.register("listRepositories") {
242     doLast {
243         println "Repositories:"
244         project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
245     }
248 tasks.register("githubTestDetails", GithubDetailsTask) {
249     text = "### [Unit Test Results Fenix]({reportsUrl}/test/testFenixDebugUnitTest/index.html)"
252 tasks.register("githubLintDetektDetails", GithubDetailsTask) {
253     text = "### [Detekt Results Fenix]({reportsUrl}/detekt.html)"
256 tasks.register("githubLintAndroidDetails", GithubDetailsTask) {
257     text = "### [Android Lint Results Fenix]({reportsUrl}/lint-results-debug.html)"