diff --git a/build.gradle b/build.gradle index 336ebde839c7..dc6c95872b74 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,12 @@ buildscript { } } - ext.kotlin_version = '1.9.22' + ext { + kotlin_version = Versions.kotlin + detekt_plugin = Versions.detekt + python_envs_plugin = Versions.python_envs_plugin + ksp_plugin = Versions.ksp_plugin + } dependencies { classpath 'org.mozilla.apilint:apilint:0.5.2' @@ -26,6 +31,11 @@ buildscript { } } +plugins { + id("io.gitlab.arturbosch.detekt").version("$detekt_plugin") + id("com.google.devtools.ksp").version("$ksp_plugin") +} + def tryInt = { string -> if (string == null) { return string @@ -404,4 +414,16 @@ subprojects { ktlint('0.49.1') } } + + project.configurations.configureEach { + resolutionStrategy.capabilitiesResolution.withCapability("org.mozilla.telemetry:glean-native") { + def toBeSelected = candidates.find { + it.id instanceof ProjectComponentIdentifier && it.id.projectName.contains('geckoview') + } + if (toBeSelected != null) { + select(toBeSelected) + } + because 'use GeckoView Glean instead of standalone Glean' + } + } } diff --git a/mobile/android/android-components/build.gradle b/mobile/android/android-components/build.gradle index 51f45bcbaba8..4d34aea3bede 100644 --- a/mobile/android/android-components/build.gradle +++ b/mobile/android/android-components/build.gradle @@ -276,8 +276,11 @@ subprojects { } } -tasks.register("clean", Delete) { - delete rootProject.layout.buildDirectory +if (findProject(":geckoview") == null) { + // Avoid adding this task if it already exists in a different root project. + tasks.register("clean", Delete) { + delete rootProject.layout.buildDirectory + } } detekt { diff --git a/mobile/android/android-components/components/browser/engine-gecko/build.gradle b/mobile/android/android-components/components/browser/engine-gecko/build.gradle index b0c6bb479784..1eef5ef762e6 100644 --- a/mobile/android/android-components/components/browser/engine-gecko/build.gradle +++ b/mobile/android/android-components/components/browser/engine-gecko/build.gradle @@ -65,7 +65,11 @@ dependencies { } implementation ComponentsDependencies.kotlin_coroutines - api ComponentsDependencies.mozilla_geckoview + if (findProject(":geckoview") != null) { + api project(':geckoview') + } else { + api ComponentsDependencies.mozilla_geckoview + } implementation ComponentsDependencies.androidx_paging implementation ComponentsDependencies.androidx_data_store_preferences diff --git a/mobile/android/android-components/samples/browser/build.gradle b/mobile/android/android-components/samples/browser/build.gradle index c4f63cc42068..351becf85be0 100644 --- a/mobile/android/android-components/samples/browser/build.gradle +++ b/mobile/android/android-components/samples/browser/build.gradle @@ -2,9 +2,17 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +if (findProject(":geckoview") != null) { + buildDir "${topobjdir}/gradle/build/mobile/android/samples-browser" +} + apply plugin: 'com.android.application' apply plugin: 'kotlin-android' +if (findProject(":geckoview") != null) { + apply from: "${topsrcdir}/mobile/android/gradle/product_flavors.gradle" +} + android { defaultConfig { applicationId "org.mozilla.samples.browser" @@ -26,7 +34,12 @@ android { } } - flavorDimensions "engine" + if (findProject(":geckoview") != null) { + project.configureProductFlavors.delegate = it + project.configureProductFlavors() + } + + flavorDimensions += "engine" productFlavors { gecko { diff --git a/settings.gradle b/settings.gradle index cf1ff4451c65..8de3818606fe 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,14 @@ +pluginManagement { + includeBuild("${rootProject.projectDir.absolutePath}/mobile/android/android-components/plugins/dependencies") + includeBuild("${rootProject.projectDir.absolutePath}/mobile/android/android-components/plugins/publicsuffixlist") + includeBuild("${rootProject.projectDir.absolutePath}/mobile/android/android-components/plugins/github") +} + +plugins { + id 'mozac.DependenciesPlugin' + id 'mozac.GitHubPlugin' +} + // You might think topsrcdir is '.', but that's not true when the Gradle build // is launched from within IntelliJ. ext.topsrcdir = rootProject.projectDir.absolutePath @@ -16,12 +27,16 @@ include ':geckoview' include ':geckoview_example' include ':test_runner' include ':exoplayer2' +include ':android-components' +include ':samples-browser' project(':annotations').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/annotations") project(':geckoview').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/geckoview") project(':geckoview_example').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/geckoview_example") project(':test_runner').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/test_runner") project(':exoplayer2').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/exoplayer2") +project(':android-components').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/android-components") +project(':samples-browser').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/android-components/samples/browser") if (hasProperty("androidFormatLintTest")) { include ':androidFormatLintTest'