Bug 1949260 - Part 1 - Replace FenixDependenciesPlugin with gradle version catalog r=android-reviewers,nalexander,jonalmeida

Differential Revision: https://phabricator.services.mozilla.com/D238809
This commit is contained in:
Aaditya Dhingra
2025-02-26 00:17:11 +00:00
parent 695882bbbf
commit a99c12afb4
11 changed files with 21 additions and 97 deletions

View File

@@ -106,5 +106,4 @@ path:mobile/android/focus-android/gradle/wrapper/gradle-wrapper.properties
path:mobile/android/fenix/gradle/wrapper/gradle-wrapper.properties
path:mobile/android/android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt
path:mobile/android/android-components/plugins/dependencies/src/main/java/ApplicationServices.kt
path:mobile/android/fenix/plugins/fenixdependencies/src/main/java/FenixDependenciesPlugin.kt
path:mobile/android/version.txt

View File

@@ -0,0 +1,7 @@
[versions]
adjust = "4.38.2"
installreferrer = "2.2"
[libraries]
adjust = { group = "com.adjust.sdk", name = "adjust-android", version.ref = "adjust" }
installreferrer = { group = "com.android.installreferrer", name = "installreferrer", version.ref = "installreferrer" }

View File

@@ -25,7 +25,7 @@ buildscript {
}
// Variables in plugins {} aren't directly supported. Hack around it by setting an
// intermediate variable which can pull from FenixDependencies.kt and be used later.
// intermediate variable which can pull from DependenciesPlugin.kt and be used later.
ext {
detekt_plugin = Versions.detekt
python_envs_plugin = Versions.python_envs_plugin
@@ -63,8 +63,9 @@ subprojects {
kotlinOptions.allWarningsAsErrors = true
}
// Prevent some dependencies from being used in AC.
// Prevent some dependencies used by Fenix/Focus from being used in AC.
project.configurations.all {
exclude group: 'com.adjust.sdk', module: 'adjust-android'
exclude group: 'io.mockk', module: 'mockk'
}

View File

@@ -708,8 +708,8 @@ dependencies {
implementation ComponentsDependencies.protobuf_javalite
implementation ComponentsDependencies.google_material
implementation FenixDependencies.adjust
implementation FenixDependencies.installreferrer // Required by Adjust
implementation(libs.adjust)
implementation(libs.installreferrer)
// Required for the Google Advertising ID
implementation ComponentsDependencies.play_services_ads_id

View File

@@ -34,7 +34,7 @@ buildscript {
}
// Variables in plugins {} aren't directly supported. Hack around it by setting an
// intermediate variable which can pull from FenixDependenciesPlugin.kt and be used later.
// intermediate variable which can pull from DependenciesPlugin.kt and be used later.
ext {
detekt_plugin = Versions.detekt
ksp_plugin = Versions.ksp_plugin

View File

@@ -1,25 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
plugins {
id "org.gradle.kotlin.kotlin-dsl" version "5.1.2"
}
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
gradlePlugin {
plugins.register("FenixDependenciesPlugin") {
id = "FenixDependenciesPlugin"
implementationClass = "FenixDependenciesPlugin"
}
}

View File

@@ -1,23 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
// Prevents gradle builds from looking for a root settings.gradle
pluginManagement {
if (!gradle.root.hasProperty("mozconfig")){
apply from: file('../../../gradle/mozconfig.gradle')
} else {
gradle.ext.mozconfig = gradle.root.mozconfig
}
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
}

View File

@@ -1,38 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
import org.gradle.api.Plugin
import org.gradle.api.initialization.Settings
// If you ever need to force a toolchain rebuild (taskcluster) then edit the following comment.
// FORCE REBUILD 2023-05-12
class FenixDependenciesPlugin : Plugin<Settings> {
override fun apply(settings: Settings) = Unit
}
object FenixVersions {
const val adjust = "4.38.2"
const val installreferrer = "2.2"
}
@Suppress("unused")
object FenixDependencies {
const val adjust = "com.adjust.sdk:adjust-android:${FenixVersions.adjust}"
const val installreferrer = "com.android.installreferrer:installreferrer:${FenixVersions.installreferrer}"
}
/**
* Functionality to limit specific dependencies to specific repositories. These are typically expected to be used by
* dependency group name (i.e. with `include/excludeGroup`). For additional info, see:
* https://docs.gradle.org/current/userguide/declaring_repositories.html#sec::matching_repositories_to_dependencies
*
* Note: I wanted to nest this in Deps but for some reason gradle can't find it so it's top-level now. :|
*/
object RepoMatching {
const val mozilla = "org\\.mozilla\\..*"
const val androidx = "androidx\\..*"
const val comAndroid = "com\\.android.*"
const val comGoogle = "com\\.google\\..*"
}

View File

@@ -24,16 +24,22 @@ pluginManagement {
includeBuild("../android-components/plugins/dependencies")
includeBuild("../android-components/plugins/config")
includeBuild("./plugins/apksize")
includeBuild("./plugins/fenixdependencies")
}
plugins {
id 'ApkSizePlugin'
id 'FenixDependenciesPlugin'
id "mozac.ConfigPlugin"
id 'mozac.DependenciesPlugin'
}
dependencyResolutionManagement {
versionCatalogs {
libs {
from(files("../../../gradle/libs.versions.toml"))
}
}
}
ext.topsrcdir = rootProject.projectDir.absolutePath.minus("mobile/android/fenix")
apply from: file('../shared-settings.gradle')

View File

@@ -23,14 +23,12 @@ 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/fenix/plugins/apksize")
includeBuild("${rootProject.projectDir.absolutePath}/mobile/android/fenix/plugins/fenixdependencies")
}
plugins {
id "mozac.ConfigPlugin"
id 'mozac.DependenciesPlugin'
id 'ApkSizePlugin'
id 'FenixDependenciesPlugin'
}
// You might think topsrcdir is '.', but that's not true when the Gradle build

View File

@@ -239,7 +239,6 @@ linux64-android-gradle-dependencies:
- 'mobile/android/gradle.configure'
- 'mobile/android/android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt'
- 'mobile/android/android-components/plugins/dependencies/src/main/java/ApplicationServices.kt'
- 'mobile/android/fenix/plugins/fenixdependencies/src/main/java/FenixDependenciesPlugin.kt'
toolchain-artifact: public/build/android-gradle-dependencies.tar.zst
toolchain-alias: android-gradle-dependencies
fetches: