mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-11 13:11:01 +00:00
78 lines
3.5 KiB
Groovy
78 lines
3.5 KiB
Groovy
include ':app'
|
|
|
|
include ':mozilla-detekt-rules'
|
|
def log(message) {
|
|
logger.lifecycle("[settings] ${message}")
|
|
}
|
|
|
|
def runCmd(cmd, workingDir, successMessage, captureStdout=true) {
|
|
def proc = cmd.execute(null, new File(workingDir))
|
|
def standardOutput = captureStdout ? new ByteArrayOutputStream() : System.out
|
|
proc.consumeProcessOutput(standardOutput, System.err)
|
|
proc.waitFor()
|
|
|
|
if (proc.exitValue() != 0) {
|
|
throw new GradleException("Process '${cmd}' finished with non-zero exit value ${proc.exitValue()}");
|
|
} else {
|
|
log(successMessage)
|
|
}
|
|
return captureStdout ? standardOutput : null
|
|
}
|
|
|
|
def gradlew = './gradlew'
|
|
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
|
gradlew += ".bat"
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Local Development overrides
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
Properties localProperties = null
|
|
String settingAppServicesPath = "autoPublish.application-services.dir"
|
|
String settingAndroidComponentsPath = "autoPublish.android-components.dir"
|
|
|
|
if (file('local.properties').canRead()) {
|
|
localProperties = new Properties()
|
|
localProperties.load(file('local.properties').newDataInputStream())
|
|
log('Loaded local.properties')
|
|
} else {
|
|
log('Missing local.properties; see https://github.com/mozilla-mobile/fenix/blob/master/README.md#local-properties-helpers for instructions.')
|
|
}
|
|
|
|
if (localProperties != null) {
|
|
localProperties.each { prop ->
|
|
gradle.ext.set("localProperties.${prop.key}", prop.value)
|
|
}
|
|
|
|
String appServicesLocalPath = localProperties.getProperty(settingAppServicesPath)
|
|
|
|
if (appServicesLocalPath != null) {
|
|
log("Enabling automatic publication of application-services from: $appServicesLocalPath")
|
|
def publishAppServicesCmd = ["./gradlew", "autoPublishForLocalDevelopment"]
|
|
runCmd(publishAppServicesCmd, appServicesLocalPath, "Published application-services for local development.", false)
|
|
} else {
|
|
log("Disabled auto-publication of application-services. Enable it by settings '$settingAppServicesPath' in local.properties")
|
|
}
|
|
|
|
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...")
|
|
def compileAcCmd = [gradlew, "compileReleaseKotlin"]
|
|
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...")
|
|
def publishAcCmd = ["${androidComponentsLocalPath}/${gradlew}", "publishToMavenLocal", "-Plocal=true"]
|
|
runCmd(publishAcCmd, androidComponentsLocalPath, "Published android-components.", false)
|
|
}
|
|
} else {
|
|
log("Disabled auto-publication of android-components. Enable it by settings '$settingAndroidComponentsPath' in local.properties")
|
|
}
|
|
}
|