2023-04-06 15:47:22 +00:00
|
|
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
|
|
|
2023-08-23 11:00:06 +00:00
|
|
|
import io.gitlab.arturbosch.detekt.Detekt
|
|
|
|
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
|
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
2023-04-06 15:47:22 +00:00
|
|
|
import java.nio.file.Files
|
|
|
|
import java.nio.file.Paths
|
|
|
|
import java.nio.file.StandardCopyOption
|
2018-12-07 20:11:50 +00:00
|
|
|
|
|
|
|
buildscript {
|
2020-04-15 17:54:36 +00:00
|
|
|
// This logic is duplicated in the allprojects block: I don't know how to fix that.
|
2018-12-07 20:11:50 +00:00
|
|
|
repositories {
|
2020-04-15 17:54:36 +00:00
|
|
|
maven {
|
2020-05-13 16:36:48 +00:00
|
|
|
name "Mozilla Nightly"
|
2020-04-15 17:54:36 +00:00
|
|
|
url "https://nightly.maven.mozilla.org/maven2"
|
|
|
|
content {
|
|
|
|
// Improve performance: only check moz maven for mozilla deps.
|
|
|
|
includeGroupByRegex RepoMatching.mozilla
|
|
|
|
}
|
|
|
|
}
|
2021-02-09 16:06:03 +00:00
|
|
|
|
2020-04-15 17:54:36 +00:00
|
|
|
maven {
|
2020-05-13 16:36:48 +00:00
|
|
|
name "Mozilla"
|
2020-04-15 17:54:36 +00:00
|
|
|
url "https://maven.mozilla.org/maven2"
|
|
|
|
content {
|
|
|
|
// Improve performance: only check moz maven for mozilla deps.
|
|
|
|
includeGroupByRegex RepoMatching.mozilla
|
|
|
|
}
|
|
|
|
}
|
2021-02-09 16:06:03 +00:00
|
|
|
|
2023-04-18 17:49:04 +00:00
|
|
|
if (ExtraRepositories.mozillaStaging) {
|
|
|
|
maven {
|
|
|
|
name "Mozilla Staging"
|
|
|
|
url "https://maven-default.stage.mozaws.net/maven2"
|
|
|
|
content {
|
|
|
|
// Improve performance: only check moz maven for mozilla deps.
|
|
|
|
includeGroupByRegex RepoMatching.mozilla
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-13 16:36:48 +00:00
|
|
|
if (project.hasProperty("googleRepo")) {
|
|
|
|
maven {
|
|
|
|
name "Google"
|
2021-07-22 16:28:06 +00:00
|
|
|
allowInsecureProtocol true // Local Nexus in CI uses HTTP
|
2020-05-13 16:36:48 +00:00
|
|
|
url project.property("googleRepo")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
google() {
|
|
|
|
content {
|
2020-10-02 22:29:56 +00:00
|
|
|
// Improve performance: only check google maven for google deps.
|
2020-05-13 16:36:48 +00:00
|
|
|
includeGroupByRegex RepoMatching.androidx
|
|
|
|
includeGroupByRegex RepoMatching.comAndroid
|
2022-10-18 07:55:46 +00:00
|
|
|
includeGroupByRegex RepoMatching.comGoogle
|
2020-05-13 16:36:48 +00:00
|
|
|
}
|
2020-04-15 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-13 16:36:48 +00:00
|
|
|
|
2021-02-09 16:06:03 +00:00
|
|
|
if (project.hasProperty("centralRepo")) {
|
|
|
|
maven {
|
|
|
|
name "MavenCentral"
|
|
|
|
url project.property("centralRepo")
|
2021-07-22 16:28:06 +00:00
|
|
|
allowInsecureProtocol true // Local Nexus in CI uses HTTP
|
2021-02-09 16:06:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mavenCentral() {
|
|
|
|
content {
|
|
|
|
// Improve security: don't search deps with known repos.
|
|
|
|
excludeGroupByRegex RepoMatching.mozilla
|
|
|
|
excludeGroupByRegex RepoMatching.androidx
|
|
|
|
excludeGroupByRegex RepoMatching.comAndroid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-07 20:11:50 +00:00
|
|
|
}
|
2020-04-15 17:54:36 +00:00
|
|
|
|
2018-12-07 20:11:50 +00:00
|
|
|
dependencies {
|
2023-06-21 16:19:45 +00:00
|
|
|
classpath ComponentsDependencies.tools_androidgradle
|
|
|
|
classpath ComponentsDependencies.tools_kotlingradle
|
2022-12-11 23:22:38 +00:00
|
|
|
classpath FenixDependencies.tools_benchmarkgradle
|
2023-08-29 17:22:31 +00:00
|
|
|
classpath FenixDependencies.androidx_safeargs
|
2022-12-11 23:22:38 +00:00
|
|
|
classpath FenixDependencies.osslicenses_plugin
|
2022-12-09 06:31:12 +00:00
|
|
|
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
|
2023-04-18 17:49:04 +00:00
|
|
|
classpath "${ApplicationServicesConfig.groupId}:tooling-nimbus-gradle:${ApplicationServicesConfig.version}"
|
2020-04-15 17:54:36 +00:00
|
|
|
|
2018-12-07 20:11:50 +00:00
|
|
|
// NOTE: Do not place your application dependencies here; they belong
|
|
|
|
// in the individual module build.gradle files
|
|
|
|
}
|
2023-05-23 19:44:55 +00:00
|
|
|
|
|
|
|
// Variables in plugins {} aren't directly supported. Hack around it by setting an
|
2023-06-08 18:53:04 +00:00
|
|
|
// intermediate variable which can pull from FenixDependenciesPlugin.kt and be used later.
|
2023-05-23 19:44:55 +00:00
|
|
|
ext {
|
2023-06-21 16:19:45 +00:00
|
|
|
detekt_plugin = Versions.detekt
|
2023-08-09 16:27:17 +00:00
|
|
|
ksp_plugin = Versions.ksp_plugin
|
2023-05-23 19:44:55 +00:00
|
|
|
protobuf_plugin = FenixVersions.protobuf_plugin
|
2023-06-21 16:19:45 +00:00
|
|
|
python_envs_plugin = Versions.python_envs_plugin
|
2023-05-23 19:44:55 +00:00
|
|
|
}
|
2018-12-07 20:11:50 +00:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:29:45 +00:00
|
|
|
plugins {
|
2023-05-23 19:44:55 +00:00
|
|
|
id("io.gitlab.arturbosch.detekt").version("$detekt_plugin")
|
2023-08-09 16:27:17 +00:00
|
|
|
id("com.google.devtools.ksp").version("$ksp_plugin")
|
2019-01-30 16:29:45 +00:00
|
|
|
}
|
|
|
|
|
2018-12-07 20:11:50 +00:00
|
|
|
allprojects {
|
2020-04-15 17:54:36 +00:00
|
|
|
// This logic is duplicated in the buildscript block: I don't know how to fix that.
|
2018-12-07 20:11:50 +00:00
|
|
|
repositories {
|
2019-01-15 18:47:38 +00:00
|
|
|
maven {
|
2020-05-13 16:36:48 +00:00
|
|
|
name "Mozilla Nightly"
|
2020-03-13 14:39:55 +00:00
|
|
|
url "https://nightly.maven.mozilla.org/maven2"
|
2020-04-15 17:54:36 +00:00
|
|
|
content {
|
|
|
|
// Improve performance: only check moz maven for mozilla deps.
|
|
|
|
includeGroupByRegex RepoMatching.mozilla
|
|
|
|
}
|
2019-01-15 18:47:38 +00:00
|
|
|
}
|
2021-02-09 16:06:03 +00:00
|
|
|
|
2019-01-07 21:47:47 +00:00
|
|
|
maven {
|
2020-05-13 16:36:48 +00:00
|
|
|
name "Mozilla"
|
2019-01-07 21:47:47 +00:00
|
|
|
url "https://maven.mozilla.org/maven2"
|
2020-04-15 17:54:36 +00:00
|
|
|
content {
|
|
|
|
// Improve performance: only check moz maven for mozilla deps.
|
|
|
|
includeGroupByRegex RepoMatching.mozilla
|
|
|
|
}
|
2019-01-07 21:47:47 +00:00
|
|
|
}
|
2021-02-09 16:06:03 +00:00
|
|
|
|
2023-04-18 17:49:04 +00:00
|
|
|
if (ExtraRepositories.mozillaStaging) {
|
|
|
|
maven {
|
|
|
|
name "Mozilla Staging"
|
|
|
|
url "https://maven-default.stage.mozaws.net/maven2"
|
|
|
|
content {
|
|
|
|
// Improve performance: only check moz maven for mozilla deps.
|
|
|
|
includeGroupByRegex RepoMatching.mozilla
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-13 16:36:48 +00:00
|
|
|
if (project.hasProperty("googleRepo")) {
|
|
|
|
maven {
|
|
|
|
name "Google"
|
|
|
|
url project.property("googleRepo")
|
2021-07-22 16:28:06 +00:00
|
|
|
allowInsecureProtocol true // Local Nexus in CI uses HTTP
|
2020-05-13 16:36:48 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
google() {
|
|
|
|
content {
|
2020-10-02 22:29:56 +00:00
|
|
|
// Improve performance: only check google maven for google deps.
|
2020-05-13 16:36:48 +00:00
|
|
|
includeGroupByRegex RepoMatching.androidx
|
|
|
|
includeGroupByRegex RepoMatching.comAndroid
|
2022-10-18 07:55:46 +00:00
|
|
|
includeGroupByRegex RepoMatching.comGoogle
|
2020-05-13 16:36:48 +00:00
|
|
|
}
|
2020-04-15 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-09 16:06:03 +00:00
|
|
|
|
|
|
|
if (project.hasProperty("centralRepo")) {
|
|
|
|
maven {
|
|
|
|
name "MavenCentral"
|
|
|
|
url project.property("centralRepo")
|
2021-07-22 16:28:06 +00:00
|
|
|
allowInsecureProtocol true // Local Nexus in CI uses HTTP
|
2021-02-09 16:06:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mavenCentral() {
|
|
|
|
content {
|
|
|
|
// Improve security: don't search deps with known repos.
|
|
|
|
excludeGroupByRegex RepoMatching.mozilla
|
|
|
|
excludeGroupByRegex RepoMatching.androidx
|
|
|
|
excludeGroupByRegex RepoMatching.comAndroid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-07 20:11:50 +00:00
|
|
|
}
|
2020-04-15 17:54:36 +00:00
|
|
|
|
2023-08-23 11:00:06 +00:00
|
|
|
tasks.withType(KotlinCompile).configureEach {
|
2023-05-22 12:18:26 +00:00
|
|
|
kotlinOptions.jvmTarget = "17"
|
2019-08-07 21:00:53 +00:00
|
|
|
kotlinOptions.allWarningsAsErrors = true
|
2020-06-03 18:18:44 +00:00
|
|
|
kotlinOptions.freeCompilerArgs += [
|
2023-08-10 08:37:59 +00:00
|
|
|
"-opt-in=kotlin.RequiresOptIn", "-Xjvm-default=all-compatibility"
|
2020-06-03 18:18:44 +00:00
|
|
|
]
|
2019-08-07 21:00:53 +00:00
|
|
|
}
|
2018-12-07 20:11:50 +00:00
|
|
|
}
|
|
|
|
|
2023-11-09 15:10:48 +00:00
|
|
|
subprojects {
|
|
|
|
afterEvaluate {
|
|
|
|
if (it.hasProperty('android')) {
|
|
|
|
android {
|
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility JavaVersion.VERSION_17
|
|
|
|
targetCompatibility JavaVersion.VERSION_17
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-04 17:56:28 +00:00
|
|
|
tasks.register('clean', Delete) {
|
2023-11-09 15:10:48 +00:00
|
|
|
delete rootProject.layout.buildDirectory
|
2019-01-15 18:47:38 +00:00
|
|
|
}
|
2019-01-30 16:29:45 +00:00
|
|
|
|
|
|
|
detekt {
|
2019-12-05 03:06:05 +00:00
|
|
|
input = files("$projectDir/app/src")
|
2019-01-30 16:29:45 +00:00
|
|
|
config = files("$projectDir/config/detekt.yml")
|
|
|
|
|
|
|
|
reports {
|
|
|
|
html {
|
|
|
|
enabled = true
|
|
|
|
destination = file("$projectDir/build/reports/detekt.html")
|
|
|
|
}
|
2019-08-21 17:52:09 +00:00
|
|
|
xml {
|
|
|
|
enabled = false
|
|
|
|
}
|
2022-01-08 19:23:08 +00:00
|
|
|
txt {
|
|
|
|
enabled = false
|
|
|
|
}
|
2019-01-30 16:29:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-23 11:00:06 +00:00
|
|
|
tasks.withType(Detekt).configureEach() {
|
2022-01-08 19:23:08 +00:00
|
|
|
autoCorrect = true
|
|
|
|
|
|
|
|
exclude "**/test/**"
|
|
|
|
exclude "**/androidTest/**"
|
|
|
|
exclude "**/build/**"
|
|
|
|
exclude "**/resources/**"
|
|
|
|
exclude "**/tmp/**"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply same path exclusions as for the main task
|
2023-08-23 11:00:06 +00:00
|
|
|
tasks.withType(DetektCreateBaselineTask).configureEach() {
|
2022-01-08 19:23:08 +00:00
|
|
|
exclude "**/test/**"
|
|
|
|
exclude "**/androidTest/**"
|
|
|
|
exclude "**/build/**"
|
|
|
|
exclude "**/resources/**"
|
|
|
|
exclude "**/tmp/**"
|
|
|
|
}
|
|
|
|
|
2019-01-30 16:29:45 +00:00
|
|
|
configurations {
|
|
|
|
ktlint
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2023-06-21 16:19:45 +00:00
|
|
|
ktlint("com.pinterest:ktlint:${Versions.ktlint}") {
|
2021-07-29 15:37:31 +00:00
|
|
|
attributes {
|
|
|
|
attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-31 16:46:22 +00:00
|
|
|
detekt project(":mozilla-detekt-rules")
|
2023-06-21 16:19:45 +00:00
|
|
|
detekt "io.gitlab.arturbosch.detekt:detekt-cli:${Versions.detekt}"
|
2019-01-30 16:29:45 +00:00
|
|
|
}
|
|
|
|
|
2020-08-04 17:56:28 +00:00
|
|
|
tasks.register('ktlint', JavaExec) {
|
|
|
|
group = "verification"
|
2019-01-30 16:29:45 +00:00
|
|
|
description = "Check Kotlin code style."
|
|
|
|
classpath = configurations.ktlint
|
2023-08-24 12:48:47 +00:00
|
|
|
mainClass.set("com.pinterest.ktlint.Main")
|
2022-09-07 06:36:07 +00:00
|
|
|
args "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
|
2019-05-29 13:19:17 +00:00
|
|
|
}
|
2020-04-01 22:42:46 +00:00
|
|
|
|
2023-08-23 13:02:54 +00:00
|
|
|
tasks.register('ktlintFormat', JavaExec) {
|
2021-07-29 15:38:00 +00:00
|
|
|
description = "Fix Kotlin code style deviations."
|
|
|
|
classpath = configurations.ktlint
|
2023-02-14 16:54:02 +00:00
|
|
|
mainClass.set("com.pinterest.ktlint.Main")
|
2022-09-07 06:36:07 +00:00
|
|
|
args "-F", "app/src/**/*.kt", "!**/build/**/*.kt", "--baseline=ktlint-baseline.xml"
|
2023-06-21 14:51:18 +00:00
|
|
|
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
|
2021-07-29 15:38:00 +00:00
|
|
|
}
|
|
|
|
|
2023-08-23 11:00:06 +00:00
|
|
|
tasks.withType(Detekt.class).configureEach {
|
2020-04-01 22:42:46 +00:00
|
|
|
exclude("**/resources/**")
|
|
|
|
exclude("**/tmp/**")
|
|
|
|
}
|
2020-05-13 16:36:48 +00:00
|
|
|
|
2020-07-10 18:24:48 +00:00
|
|
|
tasks.register("listRepositories") {
|
2020-05-13 16:36:48 +00:00
|
|
|
doLast {
|
|
|
|
println "Repositories:"
|
|
|
|
project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
|
2020-08-04 17:56:28 +00:00
|
|
|
}
|
2020-05-13 16:36:48 +00:00
|
|
|
}
|
2020-07-10 18:24:48 +00:00
|
|
|
|
|
|
|
tasks.register("githubTestDetails", GithubDetailsTask) {
|
2023-03-04 04:21:57 +00:00
|
|
|
text = "### [Unit Test Results Fenix]({reportsUrl}/test/testFenixDebugUnitTest/index.html)"
|
2020-07-10 18:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.register("githubLintDetektDetails", GithubDetailsTask) {
|
2023-01-13 16:57:58 +00:00
|
|
|
text = "### [Detekt Results Fenix]({reportsUrl}/detekt.html)"
|
2020-07-10 18:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.register("githubLintAndroidDetails", GithubDetailsTask) {
|
2023-01-13 16:57:58 +00:00
|
|
|
text = "### [Android Lint Results Fenix]({reportsUrl}/lint-results-debug.html)"
|
2020-07-10 18:24:48 +00:00
|
|
|
}
|
2023-04-06 15:47:22 +00:00
|
|
|
|
|
|
|
// Task to copy generated baseline profile to the app module nightly variant.
|
|
|
|
tasks.register("copyBaselineProfile", DefaultTask) {
|
|
|
|
doLast {
|
|
|
|
File profileFile = fileTree('benchmark/build/outputs') {
|
|
|
|
include '**/*baseline-prof.txt'
|
|
|
|
}.getSingleFile()
|
|
|
|
def destinationPath = Paths.get("app", "src", "nightly", "baselineProfiles", "baseline-prof.txt")
|
|
|
|
File destinationDir = destinationPath.toFile().parentFile
|
|
|
|
if (!destinationDir.exists()) {
|
|
|
|
destinationDir.mkdirs()
|
|
|
|
}
|
|
|
|
Files.copy(profileFile.toPath(), destinationPath, StandardCopyOption.REPLACE_EXISTING)
|
|
|
|
}
|
|
|
|
}
|