You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
3.2 KiB

  1. include ':app'
  2. include ':mozilla-detekt-rules'
  3. include ':mozilla-lint-rules'
  4. def log(message) {
  5. logger.lifecycle("[settings] ${message}")
  6. }
  7. def runCmd(cmd, workingDir, successMessage, captureStdout=true) {
  8. def proc = cmd.execute(null, new File(workingDir))
  9. def standardOutput = captureStdout ? new ByteArrayOutputStream() : System.out
  10. proc.consumeProcessOutput(standardOutput, System.err)
  11. proc.waitFor()
  12. if (proc.exitValue() != 0) {
  13. throw new GradleException("Process '${cmd}' finished with non-zero exit value ${proc.exitValue()}");
  14. } else {
  15. log(successMessage)
  16. }
  17. return captureStdout ? standardOutput : null
  18. }
  19. //////////////////////////////////////////////////////////////////////////
  20. // Local Development overrides
  21. //////////////////////////////////////////////////////////////////////////
  22. Properties localProperties = null
  23. String settingAppServicesPath = "autoPublish.application-services.dir"
  24. String settingAndroidComponentsPath = "autoPublish.android-components.dir"
  25. if (file('local.properties').canRead()) {
  26. localProperties = new Properties()
  27. localProperties.load(file('local.properties').newDataInputStream())
  28. log('Loaded local.properties')
  29. } else {
  30. log('Missing local.properties; see https://github.com/mozilla-mobile/fenix/blob/master/README.md#local-properties-helpers for instructions.')
  31. }
  32. if (localProperties != null) {
  33. localProperties.each { prop ->
  34. gradle.ext.set("localProperties.${prop.key}", prop.value)
  35. }
  36. String appServicesLocalPath = localProperties.getProperty(settingAppServicesPath)
  37. if (appServicesLocalPath != null) {
  38. log("Enabling automatic publication of application-services from: $appServicesLocalPath")
  39. // Windows can't execute .py files directly, so we assume a "manually installed" python,
  40. // which comes with a "py" launcher and respects the shebang line to specify the version.
  41. def publishAppServicesCmd = [];
  42. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  43. publishAppServicesCmd << "py";
  44. }
  45. publishAppServicesCmd << "./automation/publish_to_maven_local_if_modified.py";
  46. runCmd(publishAppServicesCmd, appServicesLocalPath, "Published application-services for local development.", false)
  47. } else {
  48. log("Disabled auto-publication of application-services. Enable it by settings '$settingAppServicesPath' in local.properties")
  49. }
  50. String androidComponentsLocalPath = localProperties.getProperty(settingAndroidComponentsPath)
  51. if (androidComponentsLocalPath != null) {
  52. log("Enabling automatic publication of android-components from: $androidComponentsLocalPath")
  53. // As above, hacks to execute .py files on Windows.
  54. def publishAcCmd = [];
  55. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  56. publishAcCmd << "py";
  57. }
  58. publishAcCmd << "./automation/publish_to_maven_local_if_modified.py";
  59. runCmd(publishAcCmd, androidComponentsLocalPath, "Published android-components for local development.", false)
  60. } else {
  61. log("Disabled auto-publication of android-components. Enable it by settings '$settingAndroidComponentsPath' in local.properties")
  62. }
  63. }