@@ -5,3 +5,74 @@ include ':app'//, ':runtime', ':runtime-binding-generator'
5
5
// project(':runtime-binding-generator').projectDir = new File("${System.env.ANDROID_RUNTIME_HOME}/test-app/runtime-binding-generator")
6
6
7
7
file(" google-services.json" ). renameTo(file(" ./app/google-services.json" ))
8
+
9
+ import org.gradle.internal.logging.text.StyledTextOutputFactory
10
+
11
+ import java.nio.file.Paths
12
+
13
+ import org.gradle.internal.logging.text.StyledTextOutputFactory
14
+ import groovy.json.JsonSlurper
15
+ import static org.gradle.internal.logging.text.StyledTextOutput.Style
16
+
17
+ def USER_PROJECT_ROOT = " $rootDir /../../"
18
+ def outLogger = services. get(StyledTextOutputFactory ). create(" colouredOutputLogger" )
19
+ def ext = {
20
+ appResourcesPath = getProperty(" appResourcesPath" )
21
+ appPath = getProperty(" appPath" )
22
+ }
23
+
24
+ def getAppPath = { ->
25
+ def relativePathToApp = " app"
26
+ def nsConfigFile = file(" $USER_PROJECT_ROOT /nsconfig.json" )
27
+ def nsConfig
28
+
29
+ if (nsConfigFile. exists()) {
30
+ nsConfig = new JsonSlurper (). parseText(nsConfigFile. getText(" UTF-8" ))
31
+ }
32
+
33
+ if (ext. appPath) {
34
+ // when appPath is passed through -PappPath=/path/to/app
35
+ // the path could be relative or absolute - either case will work
36
+ relativePathToApp = ext. appPath
37
+ } else if (nsConfig != null && nsConfig. appPath != null ) {
38
+ relativePathToApp = nsConfig. appPath
39
+ }
40
+
41
+ return Paths . get(USER_PROJECT_ROOT ). resolve(relativePathToApp). toAbsolutePath()
42
+ }
43
+
44
+
45
+ def getAppResourcesPath = { ->
46
+ def relativePathToAppResources
47
+ def absolutePathToAppResources
48
+ def nsConfigFile = file(" $USER_PROJECT_ROOT /nsconfig.json" )
49
+ def nsConfig
50
+
51
+ if (nsConfigFile. exists()) {
52
+ nsConfig = new JsonSlurper (). parseText(nsConfigFile. getText(" UTF-8" ))
53
+ }
54
+ if (ext. appResourcesPath) {
55
+ // when appResourcesPath is passed through -PappResourcesPath=/path/to/App_Resources
56
+ // the path could be relative or absolute - either case will work
57
+ relativePathToAppResources = ext. appResourcesPath
58
+ absolutePathToAppResources = Paths . get(USER_PROJECT_ROOT ). resolve(relativePathToAppResources). toAbsolutePath()
59
+ } else if (nsConfig != null && nsConfig. appResourcesPath != null ) {
60
+ relativePathToAppResources = nsConfig. appResourcesPath
61
+ absolutePathToAppResources = Paths . get(USER_PROJECT_ROOT ). resolve(relativePathToAppResources). toAbsolutePath()
62
+ } else {
63
+ absolutePathToAppResources = " ${ getAppPath()} /App_Resources"
64
+ }
65
+ return absolutePathToAppResources
66
+ }
67
+
68
+ def applySettingsGradleConfiguration = { ->
69
+ def appResourcesPath = getAppResourcesPath()
70
+ def pathToSettingsGradle = " $appResourcesPath /Android/settings.gradle"
71
+ def settingsGradle = file(pathToSettingsGradle)
72
+ if (settingsGradle. exists()) {
73
+ outLogger. withStyle(Style.SuccessHeader ). println " \t + applying user-defined configuration from ${ settingsGradle} "
74
+ apply from : pathToSettingsGradle
75
+ }
76
+ }
77
+
78
+ applySettingsGradleConfiguration()
0 commit comments