forked from mirrors/gecko-dev
Bug 1895781 - Run the App Services and Glean auto-publish scripts in settingsEvaluated. r=nalexander
This lets developers set the `autoPublish.*` properties in
`$topsrcdir/mobile/android/{project}/local.properties`. These will
override the `autoPublish.*` properties in
`$topsrcdir/local.properties` if set.
This commit also refactors the `local.properties` loading logic in
`shared-settings.gradle` to match the style used in the previous
commit.
Differential Revision: https://phabricator.services.mozilla.com/D209896
This commit is contained in:
parent
903581e523
commit
a0c36ffb32
1 changed files with 55 additions and 37 deletions
|
|
@ -201,48 +201,66 @@ def runCmd(cmd, workingDir, successMessage, captureStdout = true) {
|
||||||
// Local Development overrides
|
// Local Development overrides
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
def localPropertiesFile = new File(gradle.mozconfig.topsrcdir, "local.properties")
|
def rootLocalProperties = new File(gradle.mozconfig.topsrcdir, "local.properties").with { localPropertiesFile ->
|
||||||
if (localPropertiesFile.canRead()) {
|
|
||||||
def localProperties = new Properties()
|
def localProperties = new Properties()
|
||||||
localPropertiesFile.withInputStream { localProperties.load(it) }
|
if (localPropertiesFile.canRead()) {
|
||||||
|
localPropertiesFile.withInputStream { localProperties.load(it) }
|
||||||
|
}
|
||||||
|
localProperties
|
||||||
|
}
|
||||||
|
|
||||||
[
|
[
|
||||||
"autoPublish.application-services.dir",
|
"autoPublish.application-services.dir",
|
||||||
"autoPublish.glean.dir",
|
"autoPublish.glean.dir",
|
||||||
].each { key ->
|
].each { key ->
|
||||||
def relativeOrAbsolutePath = localProperties."$key"
|
def relativeOrAbsolutePath = rootLocalProperties."$key"
|
||||||
if (relativeOrAbsolutePath != null) {
|
if (relativeOrAbsolutePath != null) {
|
||||||
def autoPublishDir = new File(gradle.mozconfig.topsrcdir).toPath().resolve(relativeOrAbsolutePath)
|
def autoPublishDir = new File(gradle.mozconfig.topsrcdir).toPath().resolve(relativeOrAbsolutePath)
|
||||||
gradle.ext."localProperties.$key" = autoPublishDir.toString()
|
gradle.ext."localProperties.$key" = autoPublishDir.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gradle.settingsEvaluated {
|
||||||
|
if (gradle.hasProperty("localProperties.autoPublish.application-services.dir")) {
|
||||||
|
// The project that we're configuring now might have overridden
|
||||||
|
// the path from `$topsrcdir/local.properties`, so we need to
|
||||||
|
// resolve it again.
|
||||||
|
def appServicesLocalPath = gradle."localProperties.autoPublish.application-services.dir".with { relativeOrAbsolutePath ->
|
||||||
|
def absolutePath = rootDir.toPath().resolve(relativeOrAbsolutePath).toString()
|
||||||
|
gradle."localProperties.autoPublish.application-services.dir" = absolutePath
|
||||||
|
absolutePath
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gradle.hasProperty("localProperties.autoPublish.application-services.dir")) {
|
logger.lifecycle("settings.gradle> Enabling automatic publication of application-services from: $appServicesLocalPath")
|
||||||
def appServicesLocalPath = gradle."localProperties.autoPublish.application-services.dir"
|
// Windows can't execute .py files directly, so we assume a "manually installed" python,
|
||||||
logger.lifecycle("settings.gradle> Enabling automatic publication of application-services from: $appServicesLocalPath")
|
// which comes with a "py" launcher and respects the shebang line to specify the version.
|
||||||
// Windows can't execute .py files directly, so we assume a "manually installed" python,
|
def publishAppServicesCmd = [];
|
||||||
// which comes with a "py" launcher and respects the shebang line to specify the version.
|
if (System.properties["os.name"].toLowerCase().contains("windows")) {
|
||||||
def publishAppServicesCmd = [];
|
publishAppServicesCmd << "py";
|
||||||
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.", false)
|
||||||
|
} else {
|
||||||
|
logger.lifecycle("settings.gradle> Disabled auto-publication of application-services. Enable it by settings 'autoPublish.application-services.dir' in local.properties")
|
||||||
}
|
}
|
||||||
publishAppServicesCmd << "./automation/publish_to_maven_local_if_modified.py";
|
|
||||||
runCmd(publishAppServicesCmd, appServicesLocalPath, "Published application-services for local development.", false)
|
|
||||||
} else {
|
|
||||||
logger.lifecycle("settings.gradle> Disabled auto-publication of application-services. Enable it by settings 'autoPublish.application-services.dir' in local.properties")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gradle.hasProperty("localProperties.autoPublish.glean.dir")) {
|
if (gradle.hasProperty("localProperties.autoPublish.glean.dir")) {
|
||||||
def gleanLocalPath = gradle."localProperties.autoPublish.glean.dir"
|
// As above, absolutize the path.
|
||||||
logger.lifecycle("settings.gradle> Enabling automatic publication of Glean from: $gleanLocalPath")
|
def gleanLocalPath = gradle."localProperties.autoPublish.glean.dir".with { relativeOrAbsolutePath ->
|
||||||
// As above, hacks to execute .py files on Windows.
|
def absolutePath = rootDir.toPath().resolve(relativeOrAbsolutePath).toString()
|
||||||
def publishGleanCmd = [];
|
gradle."localProperties.autoPublish.glean.dir" = absolutePath
|
||||||
if (System.properties["os.name"].toLowerCase().contains("windows")) {
|
absolutePath
|
||||||
publishGleanCmd << "py";
|
}
|
||||||
|
|
||||||
|
logger.lifecycle("settings.gradle> Enabling automatic publication of Glean from: $gleanLocalPath")
|
||||||
|
// As above, hacks to execute .py files on Windows.
|
||||||
|
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.", false)
|
||||||
|
} else {
|
||||||
|
logger.lifecycle("settings.gradle> Disabled auto-publication of Glean. Enable it by settings 'autoPublish.glean.dir' in local.properties")
|
||||||
}
|
}
|
||||||
publishGleanCmd << "./build-scripts/publish_to_maven_local_if_modified.py";
|
|
||||||
runCmd(publishGleanCmd, gleanLocalPath, "Published Glean for local development.", false)
|
|
||||||
} else {
|
|
||||||
logger.lifecycle("settings.gradle> Disabled auto-publication of Glean. Enable it by settings 'autoPublish.glean.dir' in local.properties")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue