Skip to content

Commit 9e35b3f

Browse files
committed
feat(nsconfig): read app resources path from nsconfig or default
1 parent 58f95aa commit 9e35b3f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

build-artifacts/project-template-gradle/app/build.gradle

+23-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,27 @@ def renameResultApks = { variant ->
7676
///////////////////////////// CONFIGURATIONS ///////////////////////////////////////
7777
////////////////////////////////////////////////////////////////////////////////////
7878

79+
def getAppResourcesDirectory = { ->
80+
def USER_PROJECT_ROOT = "$rootDir/../.."
81+
def defaultPathToAppResources = "$USER_PROJECT_ROOT/app/App_Resources"
82+
def pathToAppResources
83+
def nsConfigFile = file("$USER_PROJECT_ROOT/nsconfig.json")
84+
85+
if (nsConfigFile.exists()) {
86+
def nsConfigJsonContent = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
87+
88+
if (nsConfigJsonContent.app_resources != null) {
89+
pathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(nsConfigJsonContent.app_resources).toAbsolutePath()
90+
} else if (nsConfigJsonContent.app_folder != null) {
91+
def pathToApp = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(nsConfigJsonContent.app_folder).toAbsolutePath();
92+
pathToAppResources = "$pathToApp/App_Resources"
93+
}
94+
}
95+
96+
return pathToAppResources != null ? pathToAppResources : defaultPathToAppResources
97+
}
98+
99+
79100
def applyPluginsIncludeGradleConfigurations = { ->
80101
def taskNames = project.getGradle().startParameter.taskNames
81102

@@ -139,7 +160,8 @@ def applyPluginsIncludeGradleConfigurations = { ->
139160
}
140161

141162
def applyAppGradleConfiguration = { ->
142-
def pathToAppGradle = "$rootDir/../../app/App_Resources/Android/app.gradle"
163+
def appResourcesDir = getAppResourcesDirectory()
164+
def pathToAppGradle = "$appResourcesDir/Android/app.gradle"
143165
def appGradle = file(pathToAppGradle)
144166
if (appGradle.exists()) {
145167
println "\t + applying user-defined configuration from ${appGradle}"

0 commit comments

Comments
 (0)