Source code
Revision control
Copy as Markdown
Other Tools
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
buildscript {
repositories {
gradle.configureMavenRepositories(delegate)
}
dependencies {
classpath libs.android.gradle.plugin
classpath libs.androidx.benchmark.gradle
classpath libs.androidx.navigation.safeargs
classpath libs.mozilla.glean.gradle.plugin
classpath libs.osslicenses.plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "mozac.ConfigPlugin"
alias(libs.plugins.dependency.analysis)
alias(libs.plugins.detekt)
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.ksp)
}
allprojects {
ext {
gleanVersion = libs.versions.glean.get()
}
}
subprojects {
project.configurations.configureEach {
// Dependencies can't depend on a different major version of Glean than A-C itself.
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'org.mozilla.telemetry'
&& details.requested.name.contains('glean') ) {
def requested = details.requested.version.tokenize(".")
def defined = project.ext.gleanVersion.tokenize(".")
// Check the major version
if (requested[0] != defined[0]) {
throw new AssertionError("Cannot resolve to a single Glean version. Requested: ${details.requested.version}, A-C uses: ${project.ext.gleanVersion}")
} else {
// Enforce that all (transitive) dependencies are using the defined Glean version
details.useVersion project.ext.gleanVersion
}
}
}
resolutionStrategy.capabilitiesResolution.withCapability("org.mozilla.telemetry:glean-native") {
def toBeSelected = candidates.find { it.id instanceof ModuleComponentIdentifier && it.id.module.contains('geckoview') }
if (toBeSelected != null) {
select(toBeSelected)
}
because 'use GeckoView Glean instead of standalone Glean'
}
}
}
tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}
dependencyAnalysis {
structure {
bundle("leakcanary") {
includeGroup("com.squareup.leakcanary")
}
bundle("mockk") {
includeGroup("io.mockk")
}
// Ignore Android KTX dependencies. See https://developer.android.com/kotlin/ktx#modules
//ignoreKtx(true)
}
issues {
all {
onAny {
// Fail the run if any issues are found (default = 'warn')
//severity('fail')
}
}
}
}
detekt {
input = files("$projectDir/app/src")
config = files("$projectDir/config/detekt.yml")
baseline = file("$projectDir/config/detekt-baseline.xml")
reports {
html {
enabled = true
destination = file("$projectDir/build/reports/detekt.html")
}
xml {
enabled = false
}
txt {
enabled = false
}
}
}
tasks.withType(Detekt).configureEach() {
autoCorrect = true
exclude "**/test/**"
exclude "**/androidTest/**"
exclude "**/build/**"
exclude "**/resources/**"
exclude "**/tmp/**"
reports {
custom {
reportId = "suppression-count"
outputLocation.set(file("$projectDir/build/reports/suppressions.txt"))
}
}
}
// Apply same path exclusions as for the main task
tasks.withType(DetektCreateBaselineTask).configureEach() {
exclude "**/test/**"
exclude "**/androidTest/**"
exclude "**/build/**"
exclude "**/resources/**"
exclude "**/tmp/**"
}
configurations {
ktlint
}
dependencies {
ktlint(libs.ktlint) {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
}
}
detekt project(":components:tooling-detekt")
detekt project(":mozilla-detekt-rules")
detekt libs.detekt.cli
}
tasks.register('ktlint', JavaExec) {
group = "verification"
description = "Check Kotlin code style."
classpath = configurations.ktlint
mainClass.set("com.pinterest.ktlint.Main")
args "app/src/**/*.kt"
args "!**/build/**/*.kt"
args "--reporter=json,output=build/reports/ktlint/ktlint.json"
args "--reporter=plain"
}
tasks.register('ktlintFormat', JavaExec) {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
mainClass.set("com.pinterest.ktlint.Main")
args "-F"
args "app/src/**/*.kt"
args "!**/build/**/*.kt"
args "--reporter=json,output=build/reports/ktlint/ktlintFormat.json"
args "--reporter=plain"
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
}
tasks.register("listRepositories") {
def reposData = project.provider {
project.repositories.collect { repo ->
[name: repo.name, url: repo.url.toString()]
}
}
doLast {
println "Repositories:"
reposData.get().each { println "Name: " + it.name + "; url: " + it.url }
}
}