Bug 1825453 - Use the same Gradle jvmargs for AC as Fenix
[gecko.git] / mobile / android / fenix / build.gradle
blobabcdcd0c4235fc889efae9bbfda31c49daea2af8
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 FenixDependencies.tools_androidgradle
63         classpath FenixDependencies.tools_kotlingradle
64         classpath FenixDependencies.tools_benchmarkgradle
65         classpath FenixDependencies.androidx_safeargs
66         classpath FenixDependencies.osslicenses_plugin
67         classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
68         classpath "org.mozilla.appservices:tooling-nimbus-gradle:${Versions.mozilla_appservices}"
70         // NOTE: Do not place your application dependencies here; they belong
71         // in the individual module build.gradle files
72     }
75 plugins {
76     id("io.gitlab.arturbosch.detekt").version("1.19.0")
79 allprojects {
80     // This logic is duplicated in the buildscript block: I don't know how to fix that.
81     repositories {
82         maven {
83             name "Mozilla Nightly"
84             url "https://nightly.maven.mozilla.org/maven2"
85             content {
86                 // Improve performance: only check moz maven for mozilla deps.
87                 includeGroupByRegex RepoMatching.mozilla
88             }
89         }
91         maven {
92             name "Mozilla"
93             url "https://maven.mozilla.org/maven2"
94             content {
95                 // Improve performance: only check moz maven for mozilla deps.
96                 includeGroupByRegex RepoMatching.mozilla
97             }
98         }
100         if (project.hasProperty("googleRepo")) {
101             maven {
102                 name "Google"
103                 url project.property("googleRepo")
104                 allowInsecureProtocol true // Local Nexus in CI uses HTTP
105             }
106         } else {
107             google() {
108                 content {
109                     // Improve performance: only check google maven for google deps.
110                     includeGroupByRegex RepoMatching.androidx
111                     includeGroupByRegex RepoMatching.comAndroid
112                     includeGroupByRegex RepoMatching.comGoogle
113                 }
114             }
115         }
117         if (project.hasProperty("centralRepo")) {
118             maven {
119                 name "MavenCentral"
120                 url project.property("centralRepo")
121                 allowInsecureProtocol true // Local Nexus in CI uses HTTP
122             }
123         } else {
124             mavenCentral() {
125                 content {
126                     // Improve security: don't search deps with known repos.
127                     excludeGroupByRegex RepoMatching.mozilla
128                     excludeGroupByRegex RepoMatching.androidx
129                     excludeGroupByRegex RepoMatching.comAndroid
130                 }
131             }
132         }
133     }
135     tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
136         kotlinOptions.jvmTarget = "11"
137         kotlinOptions.allWarningsAsErrors = true
138         kotlinOptions.freeCompilerArgs += [
139             "-opt-in=kotlin.RequiresOptIn", "-Xjvm-default=all"
140         ]
141     }
144 subprojects {
145     // Define a reusable task for updating the version in manifest.json for modules that package
146     // a web extension. We automate this to make sure we never forget to update the version, either
147     // in local development or for releases. In both cases, we want to make sure the latest version
148     // of all extensions (including their latest changes) are installed on first start-up.
149     ext.updateExtensionVersion = { task, extDir ->
150         configure(task) {
151             from extDir
152             include 'manifest.template.json'
153             rename { 'manifest.json' }
154             into extDir
156             def values = ['version': rootProject.ext.config.componentsVersion.split("a|b")[0] + "." + new Date().format('MMddHHmmss')]
157             inputs.properties(values)
158             expand(values)
159         }
160     }
163 tasks.register('clean', Delete) {
164     delete rootProject.buildDir
167 detekt {
168     input = files("$projectDir/app/src")
169     config = files("$projectDir/config/detekt.yml")
171     reports {
172         html {
173             enabled = true
174             destination = file("$projectDir/build/reports/detekt.html")
175         }
176         xml {
177             enabled = false
178         }
179         txt {
180             enabled = false
181         }
182     }
185 tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach() {
186     autoCorrect = true
188     exclude "**/test/**"
189     exclude "**/androidTest/**"
190     exclude "**/build/**"
191     exclude "**/resources/**"
192     exclude "**/tmp/**"
195 // Apply same path exclusions as for the main task
196 tasks.withType(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask).configureEach() {
197     exclude "**/test/**"
198     exclude "**/androidTest/**"
199     exclude "**/build/**"
200     exclude "**/resources/**"
201     exclude "**/tmp/**"
204 configurations {
205     ktlint
208 dependencies {
209     ktlint("com.pinterest:ktlint:0.48.2") {
210         attributes {
211             attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
212         }
213     }
215     detekt project(":mozilla-detekt-rules")
216     detekt "io.gitlab.arturbosch.detekt:detekt-cli:${FenixVersions.detekt}"
219 tasks.register('ktlint', JavaExec) {
220     group = "verification"
221     description = "Check Kotlin code style."
222     classpath = configurations.ktlint
223     main = "com.pinterest.ktlint.Main"
224     args "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
227 task ktlintFormat(type: JavaExec, group: "formatting") {
228     description = "Fix Kotlin code style deviations."
229     classpath = configurations.ktlint
230     mainClass.set("com.pinterest.ktlint.Main")
231     args "-F", "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
234 tasks.withType(io.gitlab.arturbosch.detekt.Detekt.class).configureEach {
235     exclude("**/resources/**")
236     exclude("**/tmp/**")
239 tasks.register("listRepositories") {
240     doLast {
241         println "Repositories:"
242         project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
243     }
246 tasks.register("githubTestDetails", GithubDetailsTask) {
247     text = "### [Unit Test Results Fenix]({reportsUrl}/test/testFenixDebugUnitTest/index.html)"
250 tasks.register("githubLintDetektDetails", GithubDetailsTask) {
251     text = "### [Detekt Results Fenix]({reportsUrl}/detekt.html)"
254 tasks.register("githubLintAndroidDetails", GithubDetailsTask) {
255     text = "### [Android Lint Results Fenix]({reportsUrl}/lint-results-debug.html)"