2019-12-05 03:06:05 +00:00
|
|
|
include ':app'
|
2019-03-21 19:41:41 +00:00
|
|
|
|
2019-12-31 16:46:22 +00:00
|
|
|
include ':mozilla-detekt-rules'
|
2020-03-03 18:44:54 +00:00
|
|
|
include ':mozilla-lint-rules'
|
2019-10-04 23:01:12 +00:00
|
|
|
def log(message) {
|
|
|
|
logger.lifecycle("[settings] ${message}")
|
|
|
|
}
|
|
|
|
|
2020-02-24 02:20:19 +00:00
|
|
|
def runCmd(cmd, workingDir, successMessage, captureStdout=true) {
|
2019-10-04 23:01:12 +00:00
|
|
|
def proc = cmd.execute(null, new File(workingDir))
|
2020-02-24 02:20:19 +00:00
|
|
|
def standardOutput = captureStdout ? new ByteArrayOutputStream() : System.out
|
|
|
|
proc.consumeProcessOutput(standardOutput, System.err)
|
2019-10-04 23:01:12 +00:00
|
|
|
proc.waitFor()
|
|
|
|
|
|
|
|
if (proc.exitValue() != 0) {
|
2020-02-24 02:20:19 +00:00
|
|
|
throw new GradleException("Process '${cmd}' finished with non-zero exit value ${proc.exitValue()}");
|
2019-10-04 23:01:12 +00:00
|
|
|
} else {
|
|
|
|
log(successMessage)
|
|
|
|
}
|
2020-02-24 02:20:19 +00:00
|
|
|
return captureStdout ? standardOutput : null
|
2019-10-04 23:01:12 +00:00
|
|
|
}
|
|
|
|
|
2020-02-28 05:36:27 +00:00
|
|
|
def gradlew = './gradlew'
|
|
|
|
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
|
|
|
gradlew += ".bat"
|
|
|
|
}
|
2019-03-21 19:41:41 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Local Development overrides
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-10-04 23:01:12 +00:00
|
|
|
Properties localProperties = null
|
2020-02-24 02:20:19 +00:00
|
|
|
String settingAppServicesPath = "autoPublish.application-services.dir"
|
2019-10-04 23:01:12 +00:00
|
|
|
String settingAndroidComponentsPath = "autoPublish.android-components.dir"
|
2019-03-21 19:41:41 +00:00
|
|
|
|
|
|
|
if (file('local.properties').canRead()) {
|
|
|
|
localProperties = new Properties()
|
|
|
|
localProperties.load(file('local.properties').newDataInputStream())
|
2019-10-04 23:01:12 +00:00
|
|
|
log('Loaded local.properties')
|
2019-03-21 19:41:41 +00:00
|
|
|
} else {
|
2019-10-04 23:01:12 +00:00
|
|
|
log('Missing local.properties; see https://github.com/mozilla-mobile/fenix/blob/master/README.md#local-properties-helpers for instructions.')
|
2019-03-21 19:41:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (localProperties != null) {
|
2019-08-15 21:33:40 +00:00
|
|
|
localProperties.each { prop ->
|
|
|
|
gradle.ext.set("localProperties.${prop.key}", prop.value)
|
|
|
|
}
|
|
|
|
|
2019-10-04 23:01:12 +00:00
|
|
|
String appServicesLocalPath = localProperties.getProperty(settingAppServicesPath)
|
2019-03-21 19:41:41 +00:00
|
|
|
|
|
|
|
if (appServicesLocalPath != null) {
|
2020-02-24 02:20:19 +00:00
|
|
|
log("Enabling automatic publication of application-services from: $appServicesLocalPath")
|
|
|
|
def publishAppServicesCmd = ["./gradlew", "autoPublishForLocalDevelopment"]
|
|
|
|
runCmd(publishAppServicesCmd, appServicesLocalPath, "Published application-services for local development.", false)
|
2019-03-21 19:41:41 +00:00
|
|
|
} else {
|
2020-02-24 02:20:19 +00:00
|
|
|
log("Disabled auto-publication of application-services. Enable it by settings '$settingAppServicesPath' in local.properties")
|
2019-10-04 23:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String androidComponentsLocalPath = localProperties.getProperty(settingAndroidComponentsPath)
|
|
|
|
|
|
|
|
if (androidComponentsLocalPath != null) {
|
|
|
|
log("Enabling automatic publication of android-components from: $androidComponentsLocalPath")
|
|
|
|
log("Determining if android-components are up-to-date...")
|
2020-02-28 05:36:27 +00:00
|
|
|
def compileAcCmd = [gradlew, "compileReleaseKotlin"]
|
2019-10-04 23:01:12 +00:00
|
|
|
def compileOutput = runCmd(compileAcCmd, androidComponentsLocalPath, "Compiled android-components.")
|
|
|
|
// This is somewhat brittle: parse last line of gradle output, to fish out how many tasks were executed.
|
|
|
|
// One executed task means gradle didn't do any work other than executing the top-level 'compile' task.
|
|
|
|
def compileTasksExecuted = compileOutput.toString().split('\n').last().split(':')[1].split(' ')[1]
|
|
|
|
if (compileTasksExecuted.equals("1")) {
|
|
|
|
log("android-components are up-to-date, skipping publication.")
|
|
|
|
} else {
|
|
|
|
log("android-components changed, publishing locally...")
|
2020-03-05 22:14:26 +00:00
|
|
|
def publishAcCmd = ["${androidComponentsLocalPath}/${gradlew}", "publishToMavenLocal", "-Plocal=true"]
|
2020-02-24 02:20:19 +00:00
|
|
|
runCmd(publishAcCmd, androidComponentsLocalPath, "Published android-components.", false)
|
2019-10-04 23:01:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log("Disabled auto-publication of android-components. Enable it by settings '$settingAndroidComponentsPath' in local.properties")
|
2019-03-21 19:41:41 +00:00
|
|
|
}
|
2019-10-04 23:01:12 +00:00
|
|
|
}
|