forked from mozilla-mobile/fenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.gradle
84 lines (73 loc) · 4.11 KB
/
settings.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
include ':app'
include ':mozilla-detekt-rules'
include ':mozilla-lint-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
}
//////////////////////////////////////////////////////////////////////////
// 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 = ["./automation/publish_to_maven_local_if_modified.py"]
// Application-services doesn't build on native Windows. However, it still makes sense to
// enable these workflows on Windows, even if it isn't quote as automatic as elsewhere -
// specifically, you must run the build command on WSL, but after that you can happily build
// and debug directly from within Android Studio on native Windows - but only after following
// https://github.com/mozilla/application-services/blob/master/docs/howtos/setup-android-build-environment.md#using-windows
// So rather than fail we make noise...
if (System.properties['os.name'].toLowerCase().contains('windows')) {
log('NOTE: The autoPublish workflows do not work on native windows.');
log('You must manually ensure that the following command has completed successfully in WSL:');
log("> $publishAppServicesCmd");
log("(from the '$appServicesLocalPath' directory)");
log('Then restart the build');
} else {
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) {
// android-components does build on native windows, so it doesn't get the special Windows treatment above.
// But it doesn't like executing .py files directly. We assume a "manually installed" python,
// which comes with a "py" launcher and respects the shebang line to specify the version.
log("Enabling automatic publication of android-components from: $androidComponentsLocalPath")
def publishAcCmd = [];
if (System.properties['os.name'].toLowerCase().contains('windows')) {
publishAcCmd << "py";
}
publishAcCmd << "./automation/publish_to_maven_local_if_modified.py";
runCmd(publishAcCmd, androidComponentsLocalPath, "Published android-components for local development.", false)
} else {
log("Disabled auto-publication of android-components. Enable it by settings '$settingAndroidComponentsPath' in local.properties")
}
}