Skip to content

Commit cdef0d3

Browse files
committed
chore(nsconfig): only resourcesPath in extra props for settings.gradle
1 parent 277d41b commit cdef0d3

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

test-app/app/build.gradle

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,43 @@ def computeBuildToolsVersion = { ->
6767
}
6868

6969
project.ext.selectedBuildType = project.hasProperty("release") ? "release" : "debug"
70-
project.ext.appPath = ""
7170
project.ext.appResourcesPath = ""
7271

7372
////////////////////////////////////////////////////////////////////////////////////
7473
///////////////////////////// CONFIGURATIONS ///////////////////////////////////////
7574
////////////////////////////////////////////////////////////////////////////////////
7675

77-
def getAppResourcesDirectory = { ->
78-
def defaultPathToAppResources = "$USER_PROJECT_ROOT/app/App_Resources"
79-
def pathToAppResources
76+
def getAppResourcesPath = { ->
77+
def relativePathToApp = "app"
78+
def relativePathToAppResources
79+
def absolutePathToAppResources
8080
def nsConfigFile = file("$USER_PROJECT_ROOT/nsconfig.json")
81+
def nsConfig
8182

8283
if (nsConfigFile.exists()) {
83-
def nsConfigJsonContent = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
84+
nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
85+
}
8486

85-
if (nsConfigJsonContent.appResourcesPath != null) {
86-
pathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(nsConfigJsonContent.appResourcesPath).toAbsolutePath()
87-
} else if (nsConfigJsonContent.appPath != null) {
88-
project.ext.appPath = nsConfigJsonContent.appPath
89-
pathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(nsConfigJsonContent.appPath).toAbsolutePath()
90-
}
87+
if(nsConfig != null && nsConfig.appPath != null){
88+
relativePathToApp = nsConfig.appPath
9189
}
9290

93-
def result = pathToAppResources != null ? pathToAppResources : defaultPathToAppResources
94-
project.ext.appResourcesPath = result
95-
return result
96-
}
91+
if(nsConfig != null && nsConfig.appResourcesPath != null ) {
92+
relativePathToAppResources = nsConfig.appResourcesPath
93+
} else {
94+
relativePathToAppResources = "$relativePathToApp/App_Resources"
95+
}
96+
97+
absolutePathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(relativePathToAppResources).toAbsolutePath()
98+
99+
project.ext.appResourcesPath = absolutePathToAppResources
100+
101+
return absolutePathToAppResources
102+
};
97103

98104
def applyAppGradleConfiguration = { ->
99-
def appResourcesDir = getAppResourcesDirectory()
100-
def pathToAppGradle = "$appResourcesDir/Android/app.gradle"
105+
def appResourcesPath = getAppResourcesPath()
106+
def pathToAppGradle = "$appResourcesPath/Android/app.gradle"
101107
def appGradle = file(pathToAppGradle)
102108
if (appGradle.exists()) {
103109
println "\t + applying user-defined configuration from ${appGradle}"
@@ -175,8 +181,8 @@ repositories {
175181
pluginDependencies.add("libs/runtime-libs")
176182
}
177183

178-
def localAppResources = getAppResourcesDirectory()
179-
def localAppResourcesLibraries = "$localAppResources/Android/libs"
184+
def appResourcesPath = getAppResourcesPath()
185+
def localAppResourcesLibraries = "$appResourcesPath/Android/libs"
180186

181187
pluginDependencies.add(localAppResourcesLibraries)
182188

@@ -249,8 +255,8 @@ task addDependenciesFromNativeScriptPlugins {
249255
}
250256

251257
task addDependenciesFromAppResourcesLibraries {
252-
def appResources = getAppResourcesDirectory()
253-
def appResourcesLibraries = file("$appResources/Android/libs")
258+
def appResourcesPath = getAppResourcesPath()
259+
def appResourcesLibraries = file("$appResourcesPath/Android/libs")
254260
if (appResourcesLibraries.exists()) {
255261
def aarFiles = fileTree(dir: appResourcesLibraries, include: ["**/*.aar"])
256262
aarFiles.each { aarFile ->

0 commit comments

Comments
 (0)