diff --git a/components/autofill/android/build.gradle b/components/autofill/android/build.gradle index 64b9f38656..544d15e534 100644 --- a/components/autofill/android/build.gradle +++ b/components/autofill/android/build.gradle @@ -1,5 +1,5 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.autofill' diff --git a/components/crashtest/android/build.gradle b/components/crashtest/android/build.gradle index d39c2f43a5..5a9b590442 100644 --- a/components/crashtest/android/build.gradle +++ b/components/crashtest/android/build.gradle @@ -1,5 +1,5 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.crashtest' diff --git a/components/fxa-client/android/build.gradle b/components/fxa-client/android/build.gradle index 4ef1552169..4cd2af1c27 100644 --- a/components/fxa-client/android/build.gradle +++ b/components/fxa-client/android/build.gradle @@ -2,8 +2,8 @@ plugins { alias libs.plugins.gradle.python.envs } -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" ext.gleanNamespace = "mozilla.telemetry.glean" apply plugin: "org.mozilla.telemetry.glean-gradle-plugin" diff --git a/components/logins/android/build.gradle b/components/logins/android/build.gradle index 2576cb97fc..f7ac7dc31a 100644 --- a/components/logins/android/build.gradle +++ b/components/logins/android/build.gradle @@ -2,8 +2,8 @@ plugins { alias libs.plugins.gradle.python.envs } -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" // Needs to happen before `dependencies` in order for the variables // exposed by the plugin to be available for this project. diff --git a/components/nimbus/android/build.gradle b/components/nimbus/android/build.gradle index eb6b73e444..7f730e233f 100644 --- a/components/nimbus/android/build.gradle +++ b/components/nimbus/android/build.gradle @@ -2,8 +2,8 @@ plugins { alias libs.plugins.gradle.python.envs } -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" ext.gleanYamlFiles = ["${project.projectDir}/../metrics.yaml"] ext.gleanNamespace = "mozilla.telemetry.glean" diff --git a/components/places/android/build.gradle b/components/places/android/build.gradle index 8034ce8979..9f1b7c609e 100644 --- a/components/places/android/build.gradle +++ b/components/places/android/build.gradle @@ -2,9 +2,8 @@ plugins { alias libs.plugins.gradle.python.envs } -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/build-scripts/protobuf-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" ext.gleanNamespace = "mozilla.telemetry.glean" apply plugin: "org.mozilla.telemetry.glean-gradle-plugin" diff --git a/components/push/android/build.gradle b/components/push/android/build.gradle index 2908a30c0d..ab376beaec 100644 --- a/components/push/android/build.gradle +++ b/components/push/android/build.gradle @@ -1,5 +1,5 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.push' diff --git a/components/remote_settings/android/build.gradle b/components/remote_settings/android/build.gradle index f2564d9f72..7525d7c3a3 100644 --- a/components/remote_settings/android/build.gradle +++ b/components/remote_settings/android/build.gradle @@ -1,5 +1,5 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.remotesettings' diff --git a/components/suggest/android/build.gradle b/components/suggest/android/build.gradle index 09056f3a91..284f47051f 100644 --- a/components/suggest/android/build.gradle +++ b/components/suggest/android/build.gradle @@ -1,5 +1,5 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.suggest' diff --git a/components/support/android/build.gradle b/components/support/android/build.gradle index a3bb384cb5..1d1ed40941 100644 --- a/components/support/android/build.gradle +++ b/components/support/android/build.gradle @@ -1,6 +1,6 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/build-scripts/protobuf-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/build-scripts/protobuf-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.native_support' diff --git a/components/support/error/android/build.gradle b/components/support/error/android/build.gradle index 281b3c6992..471c78c8b9 100644 --- a/components/support/error/android/build.gradle +++ b/components/support/error/android/build.gradle @@ -1,5 +1,5 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.errorsupport' diff --git a/components/support/rust-log-forwarder/android/build.gradle b/components/support/rust-log-forwarder/android/build.gradle index faf1530a27..744061538c 100644 --- a/components/support/rust-log-forwarder/android/build.gradle +++ b/components/support/rust-log-forwarder/android/build.gradle @@ -1,5 +1,5 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.rust_log_forwarder' diff --git a/components/sync15/android/build.gradle b/components/sync15/android/build.gradle index 0e0a701385..8065fb387e 100644 --- a/components/sync15/android/build.gradle +++ b/components/sync15/android/build.gradle @@ -1,5 +1,5 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.sync15' diff --git a/components/sync_manager/android/build.gradle b/components/sync_manager/android/build.gradle index a4f2f41d0e..b029acc2fb 100644 --- a/components/sync_manager/android/build.gradle +++ b/components/sync_manager/android/build.gradle @@ -2,8 +2,8 @@ plugins { alias libs.plugins.gradle.python.envs } -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" // Needs to happen before `dependencies` in order for the variables // exposed by the plugin to be available for this project. diff --git a/components/tabs/android/build.gradle b/components/tabs/android/build.gradle index 475bc8b0a5..21b109649f 100644 --- a/components/tabs/android/build.gradle +++ b/components/tabs/android/build.gradle @@ -1,5 +1,5 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.remotetabs' diff --git a/components/viaduct/android/build.gradle b/components/viaduct/android/build.gradle index 866260aed2..f063990b2f 100644 --- a/components/viaduct/android/build.gradle +++ b/components/viaduct/android/build.gradle @@ -1,6 +1,6 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/build-scripts/protobuf-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/build-scripts/protobuf-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.httpconfig' diff --git a/components/webext-storage/android/build.gradle b/components/webext-storage/android/build.gradle index 5860a876e3..a8c017557d 100644 --- a/components/webext-storage/android/build.gradle +++ b/components/webext-storage/android/build.gradle @@ -1,7 +1,7 @@ // TODO: Uncomment this code when webext-storage component is integrated in android -// apply from: "$rootDir/build-scripts/component-common.gradle" -// apply from: "$rootDir/publish.gradle" +// apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +// apply from: "$appServicesRootDir/publish.gradle" // dependencies { // // Part of the public API. diff --git a/megazords/full/android/build.gradle b/megazords/full/android/build.gradle index 8ac728e8c0..00b955ff7d 100644 --- a/megazords/full/android/build.gradle +++ b/megazords/full/android/build.gradle @@ -97,5 +97,5 @@ afterEvaluate { } } -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/publish.gradle" ext.configurePublish() diff --git a/settings.gradle b/settings.gradle index 3b43b75054..0a047b72b8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,7 +3,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import org.yaml.snakeyaml.Yaml -includeBuild('tools/nimbus-gradle-plugin') { +// We prefer `appServicesRootDir` over `rootDir` to help us on the path to the monorepo. +// (They are the same in app-services but different in moz-central) +def maybeAppServicesRootDir = new File(rootDir, "services/app-services") +def appServicesRootDir = maybeAppServicesRootDir.isDirectory() ? maybeAppServicesRootDir : rootDir; + + +includeBuild("$appServicesRootDir/tools/nimbus-gradle-plugin") { dependencySubstitution { substitute module("org.mozilla.appservices:tooling-nimbus-gradle") using(project(':')) } @@ -20,7 +26,7 @@ buildscript { rootProject.name = "appservices" -def setupProject(name, projectProps) { +def setupProject(name, projectProps, appServicesRootDir) { def path = projectProps.path def description = projectProps.description def artifactId = projectProps.artifactId @@ -32,7 +38,7 @@ def setupProject(name, projectProps) { settings.include(":$name") - project(":$name").projectDir = new File(rootDir, path) + project(":$name").projectDir = new File(appServicesRootDir, path) // project(...) gives us a skeleton project that we can't set ext.* on gradle.beforeProject { project -> @@ -43,14 +49,15 @@ def setupProject(name, projectProps) { project.ext.artifactId = artifactId // Expose the rest of the project properties, mostly for validation reasons. project.ext.configProps = projectProps + project.ext.appServicesRootDir = appServicesRootDir } } } def yaml = new Yaml() -def buildconfig = yaml.load(new File(rootDir, '.buildconfig-android.yml').newInputStream()) +def buildconfig = yaml.load(new File(appServicesRootDir, '.buildconfig-android.yml').newInputStream()) buildconfig.projects.each { project -> - setupProject(project.key, project.value) + setupProject(project.key, project.value, appServicesRootDir) } Properties localProperties = new Properties(); @@ -66,14 +73,20 @@ if (file('local.properties').canRead()) { def calcVersion(buildconfig) { def local = gradle.rootProject.findProperty("local") - def version = new File(rootDir, 'version.txt').getText().trim() - if (gradle.rootProject.hasProperty("nightlyVersion")) { + if (gradle.hasProperty("mozconfig")) { + // We are in m-c - XXX - not clear what we want for version info once in m-c, but this seems sane for now? + def buildid = file("${gradle.mozconfig.topobjdir}/buildid.h").getText('utf-8').split()[2] + return "${gradle.mozconfig.substs.MOZ_APP_VERSION}-${buildid}" + } else if (gradle.rootProject.hasProperty("nightlyVersion")) { + // We are in app-services but building a "nightly" version to be consumed by Fenix. return gradle.rootProject.nightlyVersion } else if(local) { + // We are doing a local publish return '0.0.1-SNAPSHOT' } else { - return version + // A normal build from app-services. + return new File(rootDir, 'version.txt').getText().trim() } } diff --git a/tools/start-bindings/templates/build.gradle b/tools/start-bindings/templates/build.gradle index 77aafa0eef..349d2fe912 100644 --- a/tools/start-bindings/templates/build.gradle +++ b/tools/start-bindings/templates/build.gradle @@ -1,5 +1,5 @@ -apply from: "$rootDir/build-scripts/component-common.gradle" -apply from: "$rootDir/publish.gradle" +apply from: "$appServicesRootDir/build-scripts/component-common.gradle" +apply from: "$appServicesRootDir/publish.gradle" android { namespace 'org.mozilla.appservices.{{ crate_name }}'