Bug 1951190 - Put gradle 'build' folders in TOPOBJDIR for top-level builds. r=android-reviewers,adhingra

For consistency with the rest of the build system, have gradle build folders be
created in TOPOBJDR. Put the logic in shared-settings.gradle and apply it to all
projects. Existing gradle and taskcluster configuration uses the 'gradle/build'
prefix, so continue using that for now.

Only apply this when building top-level for now since a fair bit of automation
of fenix/focus/a-c projects expects build artifacts in the source directory.

Plugins are compiled as "composite builds" so they somewhat exist in their own
world. For simplicity, just manually specify the `buildDir` for each plugin.

Differential Revision: https://phabricator.services.mozilla.com/D240116
This commit is contained in:
Ted Campbell
2025-03-15 02:03:53 +00:00
parent e1e7965a9c
commit ae94992376
18 changed files with 35 additions and 30 deletions

View File

@@ -201,8 +201,6 @@ allprojects {
} }
} }
buildDir "${topobjdir}/gradle/build"
import org.gradle.api.services.BuildServiceParameters import org.gradle.api.services.BuildServiceParameters
abstract class MozconfigService implements BuildService<MozconfigService.Params>, AutoCloseable { abstract class MozconfigService implements BuildService<MozconfigService.Params>, AutoCloseable {
interface Params extends BuildServiceParameters { interface Params extends BuildServiceParameters {

View File

@@ -6,6 +6,8 @@ plugins {
id "org.gradle.kotlin.kotlin-dsl" version "5.1.2" id "org.gradle.kotlin.kotlin-dsl" version "5.1.2"
} }
buildDir "${gradle.mozconfig.topobjdir}/gradle/build/mobile/android/android-components/plugins/config"
repositories { repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository -> gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven { maven {

View File

@@ -6,6 +6,8 @@ plugins {
id "org.gradle.kotlin.kotlin-dsl" version "5.1.2" id "org.gradle.kotlin.kotlin-dsl" version "5.1.2"
} }
buildDir "${gradle.mozconfig.topobjdir}/gradle/build/mobile/android/android-components/plugins/dependencies"
repositories { repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository -> gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven { maven {

View File

@@ -6,6 +6,8 @@ plugins {
id "org.gradle.kotlin.kotlin-dsl" version "5.1.2" id "org.gradle.kotlin.kotlin-dsl" version "5.1.2"
} }
buildDir "${gradle.mozconfig.topobjdir}/gradle/build/mobile/android/android-components/plugins/publicsuffixlist"
repositories { repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository -> gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven { maven {

View File

@@ -7,10 +7,6 @@ plugins {
alias(libs.plugins.kotlin.compose) alias(libs.plugins.kotlin.compose)
} }
if (findProject(":geckoview") != null) {
buildDir "${topobjdir}/gradle/build/mobile/android/samples-browser"
}
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {

View File

@@ -1,5 +1,3 @@
buildDir "${topobjdir}/gradle/build/mobile/android/annotations"
apply plugin: 'java' apply plugin: 'java'
dependencies { dependencies {

View File

@@ -32,7 +32,7 @@ From the root mozilla-central directory, build Fenix:
./mach gradle clean fenix:assembleDebug ./mach gradle clean fenix:assembleDebug
You can then find the generated debug apks in objdir under You can then find the generated debug apks in objdir under
``gradle/build/mobile/android/fenix/outputs/apk/fenix/debug`` ``gradle/build/mobile/android/fenix/app/outputs/apk/fenix/debug``
To sign your release builds with your debug key automatically, add the following to `<proj-root>/local.properties`: To sign your release builds with your debug key automatically, add the following to `<proj-root>/local.properties`:

View File

@@ -2,8 +2,6 @@ plugins {
alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.android)
} }
buildDir "${topobjdir}/gradle/build/mobile/android/examples/messaging_example"
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {

View File

@@ -2,8 +2,6 @@ plugins {
alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.android)
} }
buildDir "${topobjdir}/gradle/build/mobile/android/examples/port_messaging_example"
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {

View File

@@ -1,5 +1,3 @@
buildDir "${topobjdir}/gradle/build/mobile/android/exoplayer2"
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
dependencies { dependencies {

View File

@@ -25,10 +25,6 @@ plugins {
id "com.google.protobuf" version "$protobuf_plugin" id "com.google.protobuf" version "$protobuf_plugin"
} }
if (findProject(":geckoview") != null) {
buildDir "${topobjdir}/gradle/build/mobile/android/fenix"
}
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'kotlin-parcelize' apply plugin: 'kotlin-parcelize'
apply plugin: 'jacoco' apply plugin: 'jacoco'

View File

@@ -6,6 +6,8 @@ plugins {
id "org.gradle.kotlin.kotlin-dsl" version "5.1.2" id "org.gradle.kotlin.kotlin-dsl" version "5.1.2"
} }
buildDir "${gradle.mozconfig.topobjdir}/gradle/build/mobile/android/fenix/plugins/apksize"
repositories { repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository -> gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven { maven {

View File

@@ -4,10 +4,6 @@ plugins {
id "com.jetbrains.python.envs" version "$python_envs_plugin" id "com.jetbrains.python.envs" version "$python_envs_plugin"
} }
if (findProject(":geckoview") != null) {
buildDir "${topobjdir}/gradle/build/mobile/android/focus-android"
}
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'kotlin-parcelize' apply plugin: 'kotlin-parcelize'
apply plugin: 'jacoco' apply plugin: 'jacoco'

View File

@@ -2,8 +2,6 @@ plugins {
alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.android)
} }
buildDir "${topobjdir}/gradle/build/mobile/android/geckoview"
import groovy.json.JsonOutput import groovy.json.JsonOutput
apply plugin: 'com.android.library' apply plugin: 'com.android.library'

View File

@@ -2,8 +2,6 @@ plugins {
alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.android)
} }
buildDir "${topobjdir}/gradle/build/mobile/android/geckoview_example"
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {

View File

@@ -177,4 +177,29 @@ gradle.projectsLoaded { ->
} }
} }
} }
// If we are doing a top-level build, initialize all project buildDirs to be
// in ${topobjdir} to follow conventions of mozilla-central build system.
// Specific subproject builds like fenix continue to build in source tree to
// avoiding breaking existing automation.
if (findProject(":geckoview") != null) {
gradle.rootProject.allprojects { project ->
def topSrcPath = file(gradle.mozconfig.topsrcdir).toPath()
def topObjPath = file(gradle.mozconfig.topobjdir).toPath()
def sourcePath = project.getBuildFile().toPath().getParent()
def relativePath = topSrcPath.relativize(sourcePath)
if (relativePath.startsWith("..")) {
// The project doesn't appear to be in topsrcdir so leave the
// buildDir alone.
} else {
// Transplant the project path into "${topobjdir}/gradle/build".
// This is consistent with existing gradle / taskcluster
// configurations but less consistent with the result of the
// non-gradle build system.
buildDir topObjPath.resolve("gradle/build").resolve(relativePath)
}
}
}
} }

View File

@@ -2,8 +2,6 @@ plugins {
alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.android)
} }
buildDir "${topobjdir}/gradle/build/mobile/android/test_runner"
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {

View File

@@ -50,7 +50,7 @@ android-aarch64-fenix/debug:
TOOLTOOL_MANIFEST: "mobile/android/config/tooltool-manifests/android/releng.manifest" TOOLTOOL_MANIFEST: "mobile/android/config/tooltool-manifests/android/releng.manifest"
artifacts: artifacts:
- name: public/build/fenix.apk - name: public/build/fenix.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/fenix/outputs/apk/fenix/debug/fenix-fenix-x86-debug.apk path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/fenix/app/outputs/apk/fenix/debug/fenix-fenix-arm64-v8a-debug.apk
type: file type: file
run: run:
custom-build-variant-cfg: aarch64-fenix-debug custom-build-variant-cfg: aarch64-fenix-debug