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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
if (project.hasProperty("googleRepo")) {
maven {
name "Google"
url project.property("googleRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
google()
}
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
mavenCentral()
}
}
dependencies {
classpath libs.tools.android.plugin
classpath libs.kotlin.gradle.plugin
}
}
plugins {
alias libs.plugins.detekt
}
allprojects {
repositories {
if (project.hasProperty("googleRepo")) {
maven {
name "Google"
url project.property("googleRepo")
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"
}
}
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
mavenCentral()
}
}
tasks.withType(KotlinCompile).configureEach {
kotlinOptions.freeCompilerArgs += [
"-opt-in=kotlin.RequiresOptIn"
]
}
}
subprojects {
apply plugin: 'jacoco'
afterEvaluate {
if (it.hasProperty('android')) {
jacoco {
toolVersion = libs.versions.jacoco
}
android {
testOptions {
unitTests {
includeAndroidResources = true
}
}
lintOptions {
warningsAsErrors true
abortOnError true
}
}
if (project.hasProperty("coverage") && project.name != "support-test") {
tasks.withType(Test).configureEach {
jacoco.includeNoLocationClasses = true
doLast { jacocoTestReport.execute() }
}
tasks.register('jacocoTestReport', JacocoReport) {
reports {
xml.required = true
html.required = true
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*',
'**/*Test*.*', 'android/**/*.*', '**/*$[0-9].*']
def kotlinDebugTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
def javaDebugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"
sourceDirectories = files([mainSrc])
classDirectories = files([kotlinDebugTree, javaDebugTree])
executionData = fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
])
}
android {
buildTypes {
debug {
testCoverageEnabled true
}
}
}
}
}
}
}
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
detekt {
source.setFrom(files("$projectDir/components", "$projectDir/buildSrc", "$projectDir/samples"))
config.setFrom("$projectDir/config/detekt.yml")
baseline = file("$projectDir/config/detekt-baseline.xml")
}
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)
}
}
configurations {
ktlint
}
dependencies {
ktlint(libs.ktlint) {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
}
}
}
tasks.register('ktlint', JavaExec) {
description = "Check Kotlin code style."
classpath = configurations.ktlint
mainClass.set("com.pinterest.ktlint.Main")
args "app/src/**/*.kt", "!**/build/**/*.kt"
}
tasks.register('ktlintFormat', JavaExec) {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
mainClass.set("com.pinterest.ktlint.Main")
args "-F", "app/src/**/*.kt", "!**/build/**/*.kt"
}
tasks.register('listRepositories') {
doLast {
println "Repositories:"
project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
}
}