Revision control
Copy as Markdown
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import io.gitlab.arturbosch.detekt.Detekt
buildscript {
dependencies {
classpath(libs.kotlin.gradle.plugin)
}
}
plugins {
alias libs.plugins.android.application apply false
alias libs.plugins.compose.compiler apply false
alias libs.plugins.dependency.analysis
alias libs.plugins.detekt
alias libs.plugins.spotless
}
allprojects {
repositories {
def googleRepo = providers.gradleProperty("googleRepo")
if (googleRepo.present) {
maven {
name = "Google"
url = googleRepo.get()
allowInsecureProtocol = true // Local Nexus in CI uses HTTP
}
} else {
google()
}
maven {
name = "Mozilla Nightly"
content {
// Always fetch components from the snapshots repository
includeGroup "org.mozilla.components"
}
}
maven {
name = "Mozilla"
content {
// Never fetch components from here. We always want to use snapshots.
excludeGroup "org.mozilla.components"
}
}
def centralRepo = providers.gradleProperty("centralRepo")
if (centralRepo.present) {
maven {
name = "MavenCentral"
url = centralRepo.get()
allowInsecureProtocol = true // Local Nexus in CI uses HTTP
}
} else {
mavenCentral()
}
}
}
dependencyAnalysis {
structure {
ignoreKtx(true)
}
issues {
all {
onAny {
// Fail the run if any issues are found (default = 'warn')
severity('fail')
// Ignore warnings about kotlin-stdlib since we don't directly control its usage
exclude('org.jetbrains.kotlin:kotlin-stdlib')
}
onUsedTransitiveDependencies {
// We explicitly want to pull in these dependencies transitively from AC
exclude('org.mozilla.appservices.nightly:fxaclient', 'org.mozilla.geckoview:geckoview-nightly-omni')
}
}
}
}
detekt {
source.setFrom(files("$projectDir/app", "$projectDir/buildSrc"))
config.setFrom("$projectDir/config/detekt.yml")
}
tasks.withType(Detekt).configureEach {
reports {
html.required.set(true)
html.outputLocation.set(file("$projectDir/build/reports/detekt.html"))
xml.required.set(false)
txt.required.set(false)
}
}
spotless {
lineEndings = com.diffplug.spotless.LineEnding.UNIX
kotlin {
target fileTree(projectDir) {
include 'app/src/**/*.kt', 'buildSrc/src/**/*.kt'
exclude '**/build/**'
}
ktfmt(libs.versions.ktfmt.get()).kotlinlangStyle().configure {
it.setMaxWidth(120)
}
}
}
tasks.register('ktfmtCheck') {
group = "verification"
description = "Check Kotlin code style with ktfmt."
dependsOn 'spotlessKotlinCheck'
}
tasks.register('ktfmtFormat') {
group = "formatting"
description = "Format Kotlin code with ktfmt."
dependsOn 'spotlessKotlinApply'
}
tasks.register('listRepositories') {
def repositories = project.repositories.collect { "Name: ${it.name}; url: ${it.url}" }
doLast {
println "Repositories:"
repositories.each { println it }
}
}