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
6 // This logic is duplicated in the allprojects block: I don't know how to fix that.
10 url "https://nightly.maven.mozilla.org/maven2"
12 // Improve performance: only check moz maven for mozilla deps.
13 includeGroupByRegex RepoMatching.mozilla
19 url "https://maven.mozilla.org/maven2"
21 // Improve performance: only check moz maven for mozilla deps.
22 includeGroupByRegex RepoMatching.mozilla
26 if (project.hasProperty("googleRepo")) {
29 allowInsecureProtocol true // Local Nexus in CI uses HTTP
30 url project.property("googleRepo")
35 // Improve performance: only check google maven for google deps.
36 includeGroupByRegex RepoMatching.androidx
37 includeGroupByRegex RepoMatching.comAndroid
38 includeGroupByRegex RepoMatching.comGoogle
43 if (project.hasProperty("centralRepo")) {
46 url project.property("centralRepo")
47 allowInsecureProtocol true // Local Nexus in CI uses HTTP
52 // Improve security: don't search deps with known repos.
53 excludeGroupByRegex RepoMatching.mozilla
54 excludeGroupByRegex RepoMatching.androidx
55 excludeGroupByRegex RepoMatching.comAndroid
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
76 id("io.gitlab.arturbosch.detekt").version("1.19.0")
80 // This logic is duplicated in the buildscript block: I don't know how to fix that.
83 name "Mozilla Nightly"
84 url "https://nightly.maven.mozilla.org/maven2"
86 // Improve performance: only check moz maven for mozilla deps.
87 includeGroupByRegex RepoMatching.mozilla
93 url "https://maven.mozilla.org/maven2"
95 // Improve performance: only check moz maven for mozilla deps.
96 includeGroupByRegex RepoMatching.mozilla
100 if (project.hasProperty("googleRepo")) {
103 url project.property("googleRepo")
104 allowInsecureProtocol true // Local Nexus in CI uses HTTP
109 // Improve performance: only check google maven for google deps.
110 includeGroupByRegex RepoMatching.androidx
111 includeGroupByRegex RepoMatching.comAndroid
112 includeGroupByRegex RepoMatching.comGoogle
117 if (project.hasProperty("centralRepo")) {
120 url project.property("centralRepo")
121 allowInsecureProtocol true // Local Nexus in CI uses HTTP
126 // Improve security: don't search deps with known repos.
127 excludeGroupByRegex RepoMatching.mozilla
128 excludeGroupByRegex RepoMatching.androidx
129 excludeGroupByRegex RepoMatching.comAndroid
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"
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 ->
152 include 'manifest.template.json'
153 rename { 'manifest.json' }
156 def values = ['version': rootProject.ext.config.componentsVersion.split("a|b")[0] + "." + new Date().format('MMddHHmmss')]
157 inputs.properties(values)
163 tasks.register('clean', Delete) {
164 delete rootProject.buildDir
168 input = files("$projectDir/app/src")
169 config = files("$projectDir/config/detekt.yml")
174 destination = file("$projectDir/build/reports/detekt.html")
185 tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach() {
189 exclude "**/androidTest/**"
190 exclude "**/build/**"
191 exclude "**/resources/**"
195 // Apply same path exclusions as for the main task
196 tasks.withType(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask).configureEach() {
198 exclude "**/androidTest/**"
199 exclude "**/build/**"
200 exclude "**/resources/**"
209 ktlint("com.pinterest:ktlint:0.48.2") {
211 attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
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/**")
239 tasks.register("listRepositories") {
241 println "Repositories:"
242 project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
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)"