Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add appServicesRootDir attribute gradle should generally use instead … #6530

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/autofill/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions components/crashtest/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions components/fxa-client/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions components/logins/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions components/nimbus/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions components/places/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

places no longer needs protobuf.

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"
Expand Down
4 changes: 2 additions & 2 deletions components/push/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions components/remote_settings/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions components/suggest/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 3 additions & 3 deletions components/support/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions components/support/error/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions components/support/rust-log-forwarder/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions components/sync15/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions components/sync_manager/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions components/tabs/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 3 additions & 3 deletions components/viaduct/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions components/webext-storage/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion megazords/full/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ afterEvaluate {
}
}

apply from: "$rootDir/publish.gradle"
apply from: "$appServicesRootDir/publish.gradle"
ext.configurePublish()
29 changes: 21 additions & 8 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of this probably highlights my poor groovy/gradle skills, but I couldn't work out a sane way to share this variable both out and inside setupProject, so this is what I came up with.

def appServicesRootDir = maybeAppServicesRootDir.isDirectory() ? maybeAppServicesRootDir : rootDir;


includeBuild("$appServicesRootDir/tools/nimbus-gradle-plugin") {
dependencySubstitution {
substitute module("org.mozilla.appservices:tooling-nimbus-gradle") using(project(':'))
}
Expand All @@ -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
Expand All @@ -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 ->
Expand All @@ -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();
Expand All @@ -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")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get something sane from a build in m-c - not clear how (or even if) we need a dedicated version string once landed.

// 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()
}
}

Expand Down
4 changes: 2 additions & 2 deletions tools/start-bindings/templates/build.gradle
Original file line number Diff line number Diff line change
@@ -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 }}'
Expand Down