1 // Top-level build file where you can add configuration options common to all sub-projects/modules.
4 // This logic is duplicated in the allprojects block: I don't know how to fix that.
8 url "https://nightly.maven.mozilla.org/maven2"
10 // Improve performance: only check moz maven for mozilla deps.
11 includeGroupByRegex RepoMatching.mozilla
17 url "https://maven.mozilla.org/maven2"
19 // Improve performance: only check moz maven for mozilla deps.
20 includeGroupByRegex RepoMatching.mozilla
24 if (ExtraRepositories.mozillaStaging) {
26 name "Mozilla Staging"
27 url "https://maven-default.stage.mozaws.net/maven2"
29 // Improve performance: only check moz maven for mozilla deps.
30 includeGroupByRegex RepoMatching.mozilla
35 if (project.hasProperty("googleRepo")) {
38 allowInsecureProtocol true // Local Nexus in CI uses HTTP
39 url project.property("googleRepo")
44 // Improve performance: only check google maven for google deps.
45 includeGroupByRegex RepoMatching.androidx
46 includeGroupByRegex RepoMatching.comAndroid
47 includeGroupByRegex RepoMatching.comGoogle
52 if (project.hasProperty("centralRepo")) {
55 url project.property("centralRepo")
56 allowInsecureProtocol true // Local Nexus in CI uses HTTP
61 // Improve security: don't search deps with known repos.
62 excludeGroupByRegex RepoMatching.mozilla
63 excludeGroupByRegex RepoMatching.androidx
64 excludeGroupByRegex RepoMatching.comAndroid
71 classpath ComponentsDependencies.tools_androidgradle
72 classpath ComponentsDependencies.tools_kotlingradle
73 classpath FenixDependencies.tools_benchmarkgradle
74 classpath FenixDependencies.androidx_safeargs
75 classpath FenixDependencies.osslicenses_plugin
76 classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
77 classpath "${ApplicationServicesConfig.groupId}:tooling-nimbus-gradle:${ApplicationServicesConfig.version}"
79 // NOTE: Do not place your application dependencies here; they belong
80 // in the individual module build.gradle files
83 // Variables in plugins {} aren't directly supported. Hack around it by setting an
84 // intermediate variable which can pull from FenixDependenciesPlugin.kt and be used later.
86 detekt_plugin = Versions.detekt
87 protobuf_plugin = FenixVersions.protobuf_plugin
88 python_envs_plugin = Versions.python_envs_plugin
93 id("io.gitlab.arturbosch.detekt").version("$detekt_plugin")
97 // This logic is duplicated in the buildscript block: I don't know how to fix that.
100 name "Mozilla Nightly"
101 url "https://nightly.maven.mozilla.org/maven2"
103 // Improve performance: only check moz maven for mozilla deps.
104 includeGroupByRegex RepoMatching.mozilla
110 url "https://maven.mozilla.org/maven2"
112 // Improve performance: only check moz maven for mozilla deps.
113 includeGroupByRegex RepoMatching.mozilla
117 if (ExtraRepositories.mozillaStaging) {
119 name "Mozilla Staging"
120 url "https://maven-default.stage.mozaws.net/maven2"
122 // Improve performance: only check moz maven for mozilla deps.
123 includeGroupByRegex RepoMatching.mozilla
128 if (project.hasProperty("googleRepo")) {
131 url project.property("googleRepo")
132 allowInsecureProtocol true // Local Nexus in CI uses HTTP
137 // Improve performance: only check google maven for google deps.
138 includeGroupByRegex RepoMatching.androidx
139 includeGroupByRegex RepoMatching.comAndroid
140 includeGroupByRegex RepoMatching.comGoogle
145 if (project.hasProperty("centralRepo")) {
148 url project.property("centralRepo")
149 allowInsecureProtocol true // Local Nexus in CI uses HTTP
154 // Improve security: don't search deps with known repos.
155 excludeGroupByRegex RepoMatching.mozilla
156 excludeGroupByRegex RepoMatching.androidx
157 excludeGroupByRegex RepoMatching.comAndroid
163 tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
164 kotlinOptions.jvmTarget = "17"
165 kotlinOptions.allWarningsAsErrors = true
166 kotlinOptions.freeCompilerArgs += [
167 "-opt-in=kotlin.RequiresOptIn", "-Xjvm-default=all"
172 tasks.register('clean', Delete) {
173 delete rootProject.buildDir
177 input = files("$projectDir/app/src")
178 config = files("$projectDir/config/detekt.yml")
183 destination = file("$projectDir/build/reports/detekt.html")
194 tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach() {
198 exclude "**/androidTest/**"
199 exclude "**/build/**"
200 exclude "**/resources/**"
204 // Apply same path exclusions as for the main task
205 tasks.withType(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask).configureEach() {
207 exclude "**/androidTest/**"
208 exclude "**/build/**"
209 exclude "**/resources/**"
218 ktlint("com.pinterest:ktlint:${Versions.ktlint}") {
220 attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
224 detekt project(":mozilla-detekt-rules")
225 detekt "io.gitlab.arturbosch.detekt:detekt-cli:${Versions.detekt}"
228 tasks.register('ktlint', JavaExec) {
229 group = "verification"
230 description = "Check Kotlin code style."
231 classpath = configurations.ktlint
232 main = "com.pinterest.ktlint.Main"
233 args "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
236 task ktlintFormat(type: JavaExec, group: "formatting") {
237 description = "Fix Kotlin code style deviations."
238 classpath = configurations.ktlint
239 mainClass.set("com.pinterest.ktlint.Main")
240 args "-F", "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
241 jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
244 tasks.withType(io.gitlab.arturbosch.detekt.Detekt.class).configureEach {
245 exclude("**/resources/**")
249 tasks.register("listRepositories") {
251 println "Repositories:"
252 project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
256 tasks.register("githubTestDetails", GithubDetailsTask) {
257 text = "### [Unit Test Results Fenix]({reportsUrl}/test/testFenixDebugUnitTest/index.html)"
260 tasks.register("githubLintDetektDetails", GithubDetailsTask) {
261 text = "### [Detekt Results Fenix]({reportsUrl}/detekt.html)"
264 tasks.register("githubLintAndroidDetails", GithubDetailsTask) {
265 text = "### [Android Lint Results Fenix]({reportsUrl}/lint-results-debug.html)"