Bug 1895781 - Restore project-specific local.properties for Fenix and Focus. r=nalexander

This commit partially reverts the changes in bug 1888422, to fix an
issue where the contents of `mobile/android/{project}/local.properties`
wouldn't be loaded into `gradle.ext` properties. This broke the ability
to set project-specific properties like `autosignReleaseWithDebugKey`,
`debuggable`, `nimbus`, `glean`, `official`, `mozillaOnline`, etc.

This commit also reverts moving the GeckoView substitution logic into
`shared-settings.gradle`, because it's only needed for Android
Components and Fenix.

Differential Revision: https://phabricator.services.mozilla.com/D209895
This commit is contained in:
Lina Butler
2024-05-10 06:21:28 +00:00
parent 557b510a75
commit 434173835a
6 changed files with 44 additions and 69 deletions

View File

@@ -89,6 +89,13 @@ subprojects {
}
}
if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopsrcdir')) {
if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopobjdir')) {
ext.topobjdir = gradle."localProperties.dependencySubstitutions.geckoviewTopobjdir"
}
ext.topsrcdir = gradle."localProperties.dependencySubstitutions.geckoviewTopsrcdir"
apply from: "${topsrcdir}/substitute-local-geckoview.gradle"
}
afterEvaluate {
if (it.hasProperty('android')) {

View File

@@ -35,67 +35,13 @@ buildCache {
}
}
def runCmd(cmd, workingDir, successMessage) {
def proc = cmd.execute(null, new File(workingDir))
proc.consumeProcessOutput(System.out, System.err)
proc.waitFor()
if (proc.exitValue() != 0) {
throw new GradleException("Process '${cmd}' finished with non-zero exit value ${proc.exitValue()}")
} else {
logger.lifecycle(successMessage)
def projectLocalProperties = file("local.properties").with { localPropertiesFile ->
def localProperties = new Properties()
if (localPropertiesFile.canRead()) {
localPropertiesFile.withInputStream { localProperties.load(it) }
}
localProperties
}
//////////////////////////////////////////////////////////////////////////
// Local Development overrides
//////////////////////////////////////////////////////////////////////////
Properties localProperties = null;
String settingAppServicesPath = "autoPublish.application-services.dir"
String settingGleanPath = "autoPublish.glean.dir";
if (file('local.properties').canRead()) {
localProperties = new Properties()
localProperties.load(file('local.properties').newDataInputStream())
logger.lifecycle('Local configuration: loaded local.properties')
} else {
logger.lifecycle('Local configuration: absent local.properties; proceeding as normal.')
}
if (localProperties != null) {
localProperties.each { prop ->
gradle.ext.set("localProperties.${prop.key}", prop.value)
}
String appServicesLocalPath = localProperties.getProperty(settingAppServicesPath);
if (appServicesLocalPath != null) {
logger.lifecycle("Enabling automatic publication of application-services from: $appServicesLocalPath")
// Windows can't execute .py files directly, so we assume a "manually installed" python,
// which comes with a "py" launcher and respects the shebang line to specify the version.
def publishAppServicesCmd = [];
if (System.properties['os.name'].toLowerCase().contains('windows')) {
publishAppServicesCmd << "py";
}
publishAppServicesCmd << "./automation/publish_to_maven_local_if_modified.py";
runCmd(publishAppServicesCmd, appServicesLocalPath, "Published application-services for local development.")
} else {
logger.lifecycle("Disabled auto-publication of application-services. Enable it by settings '$settingAppServicesPath' in local.properties")
}
String gleanLocalPath = localProperties.getProperty(settingGleanPath);
if (gleanLocalPath != null) {
logger.lifecycle("Enabling automatic publication of Glean from: $gleanLocalPath")
// Windows can't execute .py files directly, so we assume a "manually installed" python,
// which comes with a "py" launcher and respects the shebang line to specify the version.
def publishGleanCmd = [];
if (System.properties['os.name'].toLowerCase().contains('windows')) {
publishGleanCmd << "py";
}
publishGleanCmd << "./build-scripts/publish_to_maven_local_if_modified.py";
runCmd(publishGleanCmd, gleanLocalPath, "Published Glean for local development.")
} else {
logger.lifecycle("Disabled auto-publication of Glean. Enable it by settings '$settingGleanPath' in local.properties")
}
projectLocalProperties.each { prop ->
gradle.ext."localProperties.${prop.key}" = prop.value
}

View File

@@ -890,6 +890,14 @@ afterEvaluate {
}
}
if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopsrcdir')) {
if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopobjdir')) {
ext.topobjdir = gradle."localProperties.dependencySubstitutions.geckoviewTopobjdir"
}
ext.topsrcdir = gradle."localProperties.dependencySubstitutions.geckoviewTopsrcdir"
apply from: "${topsrcdir}/substitute-local-geckoview.gradle"
}
android.applicationVariants.configureEach { variant ->
tasks.register("apkSize${variant.name.capitalize()}", ApkSizeTask) {
variantName = variant.name

View File

@@ -54,3 +54,14 @@ gradle.projectsLoaded { ->
}
}
}
def projectLocalProperties = file("local.properties").with { localPropertiesFile ->
def localProperties = new Properties()
if (localPropertiesFile.canRead()) {
localPropertiesFile.withInputStream { localProperties.load(it) }
}
localProperties
}
projectLocalProperties.each { prop ->
gradle.ext."localProperties.${prop.key}" = prop.value
}

View File

@@ -49,3 +49,14 @@ gradle.projectsLoaded { ->
}
}
}
def projectLocalProperties = file("local.properties").with { localPropertiesFile ->
def localProperties = new Properties()
if (localPropertiesFile.canRead()) {
localPropertiesFile.withInputStream { localProperties.load(it) }
}
localProperties
}
projectLocalProperties.each { prop ->
gradle.ext."localProperties.${prop.key}" = prop.value
}

View File

@@ -180,14 +180,6 @@ gradle.projectsLoaded { ->
def gleanSrcDir = gradle."localProperties.autoPublish.glean.dir"
apply from: "${gleanSrcDir}/build-scripts/substitute-local-glean.gradle"
}
if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopsrcdir')) {
if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopobjdir')) {
ext.topobjdir = gradle."localProperties.dependencySubstitutions.geckoviewTopobjdir"
}
ext.topsrcdir = gradle."localProperties.dependencySubstitutions.geckoviewTopsrcdir"
apply from: "${topsrcdir}/substitute-local-geckoview.gradle"
}
}
}