Bug 1837451 - Refactor FocusDependencies into a plugin using composite build
[gecko.git] / mobile / android / focus-android / build.gradle
blobe5112d6b5e651c06a74664b77cbccba74a432398
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         }
17         if (ExtraRepositories.mozillaStaging) {
18             maven {
19                 name "Mozilla Staging"
20                 url "https://maven-default.stage.mozaws.net/maven2"
21             }
22         }
23     }
25     dependencies {
26         classpath FocusDependencies.android_gradle_plugin
27         classpath FocusDependencies.kotlin_gradle_plugin
28         classpath FocusDependencies.osslicenses_plugin
29         classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
30         classpath "${ApplicationServicesConfig.groupId}:tooling-nimbus-gradle:${ApplicationServicesConfig.version}"
32         // NOTE: Do not place your application dependencies here; they belong
33         // in the individual module build.gradle files
34     }
36     // Variables in plugins {} aren't directly supported. Hack around it by setting an
37     // intermediate variable which can pull from FocusDependenciesPlugin.kt and be used later.
38     ext {
39         detekt_plugin = FocusVersions.detekt_version
40         python_envs_plugin = FocusVersions.python_envs_plugin_version
41     }
44 plugins {
45     id "io.gitlab.arturbosch.detekt" version "$detekt_plugin"
48 detekt {
49     input = files("$projectDir/app")
50     config = files("$projectDir/quality/detekt.yml")
51     baseline = file("$projectDir/quality/detekt-baseline.xml")
53     reports {
54         html {
55             enabled = true
56             destination = file("$projectDir/build/reports/detekt.html")
57         }
58         xml {
59             enabled = false
60         }
61         txt {
62             enabled = false
63         }
64     }
67 tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach() {
68     autoCorrect = true
70     exclude "**/test/**"
71     exclude "**/androidTest/**"
72     exclude "**/build/**"
73     exclude "**/resources/**"
74     exclude "**/tmp/**"
77 // Apply same path exclusions as for the main task
78 tasks.withType(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask).configureEach() {
79     exclude "**/test/**"
80     exclude "**/androidTest/**"
81     exclude "**/build/**"
82     exclude "**/resources/**"
83     exclude "**/tmp/**"
86 allprojects {
87     repositories {
88         google()
89         mavenCentral()
90         maven {
91             url "https://nightly.maven.mozilla.org/maven2"
92         }
93         maven {
94             url "https://maven.mozilla.org/maven2"
95         }
97         if (ExtraRepositories.mozillaStaging) {
98             maven {
99                 name "Mozilla Staging"
100                 url "https://maven-default.stage.mozaws.net/maven2"
101             }
102         }
103     }
106 task clean(type: Delete) {
107     delete rootProject.buildDir
111 configurations {
112     ktlint
115 dependencies {
116     ktlint("com.pinterest:ktlint:${FocusVersions.ktlint_version}") {
117         attributes {
118             attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
119         }
120     }
123 task ktlint(type: JavaExec, group: "verification") {
124     description = "Check Kotlin code style."
125     classpath = configurations.ktlint
126     main = "com.pinterest.ktlint.Main"
127     args "app/**/*.kt", "!**/build/**/*.kt", "buildSrc/**/*.kt"
131 task ktlintFormat(type: JavaExec, group: "formatting") {
132     description = "Fix Kotlin code style deviations."
133     classpath = configurations.ktlint
134     mainClass.set("com.pinterest.ktlint.Main")
135     args "-F", "app/**/*.kt", "!**/build/**/*.kt", "buildSrc/**/*.kt"
138 tasks.register("listRepositories") {
139     doLast {
140         println "Repositories:"
141         project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
142    }
145 tasks.register("githubTestDetails", GithubDetailsTask) {
146     text = "### [Unit Test Results]({reportsUrl}/test/testFocusDebugUnitTest/index.html)"
149 tasks.register("githubLintDetektDetails", GithubDetailsTask) {
150     text = "### [Detekt Results Focus]({reportsUrl}/detekt.html)"
153 tasks.register("githubLintAndroidDetails", GithubDetailsTask) {
154     text = "### [Android Lint Results Focus]({reportsUrl}/lint-results-debug.html)"