Bug 1806170 - Align detekt config between Focus and Android Components
[gecko.git] / mobile / android / focus-android / build.gradle
blob0da8fd4d17dfc17d298274f5c6ec5935c37c20bc
1 // Top-level build file where you can add configuration options common to all sub-projects/modules.
3 import org.mozilla.focus.gradle.tasks.GithubDetailsTask
5 buildscript {
6     repositories {
7         google()
8         mavenCentral()
9         maven {
10             // We will always need this repository for retrieving stable dependencies (like Glean).
11             url "https://maven.mozilla.org/maven2"
12         }
13         maven {
14             url "https://nightly.maven.mozilla.org/maven2"
15         }
16     }
18     dependencies {
19         classpath FocusDependencies.android_gradle_plugin
20         classpath FocusDependencies.kotlin_gradle_plugin
21         classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
22         // NOTE: The Nimbus plugin needs to be refactored into a top-level plugin
23         // and consumed via includeBuild (using composite builds). This is a short-term
24         // workaround to consume the latest version of the Nimbus plugin matching the Focus version.
25         if (Config.readVersionFromFile().contains("a")) {
26             // Use the latest version of the plugin on the main branch (nightly).
27             classpath("org.mozilla.components:tooling-nimbus-gradle:latest.release")
28         } else {
29             // Use the latest version matching the major version of the branch (beta/release).
30             classpath("org.mozilla.components:tooling-nimbus-gradle") {
31                 version {
32                     strictly("${Config.majorVersion()}.+")
33                 }
34             }
35         }
37         // NOTE: Do not place your application dependencies here; they belong
38         // in the individual module build.gradle files
39     }
42 plugins {
43     id "io.gitlab.arturbosch.detekt" version "1.19.0" // Variables in plugins {} aren't supported
46 detekt {
47     buildUponDefaultConfig = true
48     input = files("$projectDir/app")
49     config = files("$projectDir/quality/detekt.yml")
50     baseline = file("$projectDir/quality/detekt-baseline.xml")
52     reports {
53         html {
54             enabled = true
55             destination = file("$projectDir/build/reports/detekt.html")
56         }
57     }
60 allprojects {
61     repositories {
62         google()
63         mavenCentral()
64         maven {
65             url "https://nightly.maven.mozilla.org/maven2"
66         }
67         maven {
68             url "https://maven.mozilla.org/maven2"
69         }
70     }
73 subprojects {
74     // Define a reusable task for updating the version in manifest.json for modules that package
75     // a web extension. We automate this to make sure we never forget to update the version, either
76     // in local development or for releases. In both cases, we want to make sure the latest version
77     // of all extensions (including their latest changes) are installed on first start-up.
78     ext.updateExtensionVersion = { task, extDir ->
79         configure(task) {
80             from extDir
81             include 'manifest.template.json'
82             rename { 'manifest.json' }
83             into extDir
85             def values = ['version': rootProject.ext.config.componentsVersion + "." + new Date().format('MMddHHmmss')]
86             inputs.properties(values)
87             expand(values)
88         }
89     }
92 task clean(type: Delete) {
93     delete rootProject.buildDir
97 configurations {
98     ktlint
101 dependencies {
102     ktlint("com.pinterest:ktlint:${FocusVersions.ktlint_version}") {
103         attributes {
104             attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
105         }
106     }
109 task ktlint(type: JavaExec, group: "verification") {
110     description = "Check Kotlin code style."
111     classpath = configurations.ktlint
112     main = "com.pinterest.ktlint.Main"
113     args "app/**/*.kt", "!**/build/**/*.kt", "buildSrc/**/*.kt"
117 task ktlintFormat(type: JavaExec, group: "formatting") {
118     description = "Fix Kotlin code style deviations."
119     classpath = configurations.ktlint
120     main = "com.pinterest.ktlint.Main"
121     args "-F", "app/**/*.kt", "!**/build/**/*.kt", "buildSrc/**/*.kt"
124 tasks.register("listRepositories") {
125     doLast {
126         println "Repositories:"
127         project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
128    }
131 tasks.register("githubTestDetails", GithubDetailsTask) {
132     text = "### [Unit Test Results]({reportsUrl}/test/testFocusDebugUnitTest/index.html)"
135 tasks.register("githubLintDetektDetails", GithubDetailsTask) {
136     text = "### [Detekt Results Focus]({reportsUrl}/detekt.html)"
139 tasks.register("githubLintAndroidDetails", GithubDetailsTask) {
140     text = "### [Android Lint Results Focus]({reportsUrl}/lint-results-debug.html)"