@@ -72,6 +72,55 @@ buildscript {
7272 logger. warn " \t + failed to load gradle properties from \" $path \" . Error is: ${ ex.getMessage()} "
7373 }
7474 }
75+ def getAppResourcesPath = { ->
76+ def relativePathToAppResources
77+ def absolutePathToAppResources
78+ def nsConfigFile = file(" $USER_PROJECT_ROOT /nsconfig.json" )
79+ def nsConfig
80+
81+ if (nsConfigFile. exists()) {
82+ nsConfig = new JsonSlurper (). parseText(nsConfigFile. getText(" UTF-8" ))
83+ }
84+
85+ if (project. hasProperty(" appResourcesPath" )) {
86+ // when appResourcesPath is passed through -PappResourcesPath=/path/to/App_Resources
87+ // the path could be relative or absolute - either case will work
88+ relativePathToAppResources = appResourcesPath
89+ absolutePathToAppResources = Paths . get(USER_PROJECT_ROOT ). resolve(relativePathToAppResources). toAbsolutePath()
90+ } else if (nsConfig != null && nsConfig. appResourcesPath != null ) {
91+ relativePathToAppResources = nsConfig. appResourcesPath
92+ absolutePathToAppResources = Paths . get(USER_PROJECT_ROOT ). resolve(relativePathToAppResources). toAbsolutePath()
93+ } else {
94+ absolutePathToAppResources = " ${ getAppPath()} /App_Resources"
95+ }
96+
97+ project. ext. appResourcesPath = absolutePathToAppResources
98+
99+ return absolutePathToAppResources
100+ }
101+
102+
103+ def getAppPath = { ->
104+ def relativePathToApp = " app"
105+ def nsConfigFile = file(" $USER_PROJECT_ROOT /nsconfig.json" )
106+ def nsConfig
107+
108+ if (nsConfigFile. exists()) {
109+ nsConfig = new JsonSlurper (). parseText(nsConfigFile. getText(" UTF-8" ))
110+ }
111+
112+ if (project. hasProperty(" appPath" )) {
113+ // when appPath is passed through -PappPath=/path/to/app
114+ // the path could be relative or absolute - either case will work
115+ relativePathToApp = appPath
116+ } else if (nsConfig != null && nsConfig. appPath != null ) {
117+ relativePathToApp = nsConfig. appPath
118+ }
119+
120+ project. ext. appPath = Paths . get(USER_PROJECT_ROOT ). resolve(relativePathToApp). toAbsolutePath()
121+
122+ return project. ext. appPath
123+ }
75124 def initialize = { ->
76125 // set up our logger
77126 project. ext. outLogger = services. get(StyledTextOutputFactory ). create(" colouredOutputLogger" )
@@ -83,7 +132,7 @@ buildscript {
83132 project. ext. PLUGIN_NAME = " {{pluginName}}"
84133
85134 def userDir = " $USER_PROJECT_ROOT "
86- rootProject. ext. userDefinedGradleProperties = getUserProperties(" ${ getAppResourcesPath(USER_PROJECT_ROOT )} /Android" )
135+ rootProject. ext. userDefinedGradleProperties = getUserProperties(" ${ getAppResourcesPath()} /Android" )
87136
88137 loadPropertyFile(" $USER_PROJECT_ROOT /${ project.ext.PLATFORMS_ANDROID} /gradle.properties" )
89138 loadPropertyFile(" $USER_PROJECT_ROOT /${ project.ext.PLATFORMS_ANDROID} /additional_gradle.properties" )
@@ -160,35 +209,6 @@ buildscript {
160209
161210 return project. ext. appPath
162211 }
163-
164- project. ext. getAppResourcesPath = { ->
165- def relativePathToAppResources
166- def absolutePathToAppResources
167- def nsConfigFile = file(" $USER_PROJECT_ROOT /nsconfig.json" )
168- def nsConfig
169-
170- if (nsConfigFile. exists()) {
171- nsConfig = new JsonSlurper (). parseText(nsConfigFile. getText(" UTF-8" ))
172- }
173-
174- if (project. hasProperty(" appResourcesPath" )) {
175- // when appResourcesPath is passed through -PappResourcesPath=/path/to/App_Resources
176- // the path could be relative or absolute - either case will work
177- relativePathToAppResources = appResourcesPath
178- absolutePathToAppResources = Paths . get(USER_PROJECT_ROOT ). resolve(relativePathToAppResources). toAbsolutePath()
179- } else if (nsConfig != null && nsConfig. appResourcesPath != null ) {
180- relativePathToAppResources = nsConfig. appResourcesPath
181- absolutePathToAppResources = Paths . get(USER_PROJECT_ROOT ). resolve(relativePathToAppResources). toAbsolutePath()
182- } else {
183- absolutePathToAppResources = " ${ getAppPath()} /App_Resources"
184- }
185-
186- project. ext. appResourcesPath = absolutePathToAppResources
187-
188- return absolutePathToAppResources
189- }
190-
191-
192212 }
193213 def applyBuildScriptConfigurations = { ->
194214 def absolutePathToAppResources = getAppResourcesPath()
0 commit comments