Skip to content

Commit

Permalink
feat(nsconfig): read app resources path from nsconfig or default
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianDD committed Feb 23, 2018
1 parent 1a73c56 commit 9edaaaf
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion build-artifacts/project-template-gradle/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,27 @@ def renameResultApks = { variant ->
///////////////////////////// CONFIGURATIONS ///////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////

def getAppResourcesDirectory = { ->
def USER_PROJECT_ROOT = "$rootDir/../.."
def defaultPathToAppResources = "$USER_PROJECT_ROOT/app/App_Resources"
def pathToAppResources
def nsConfigFile = file("$USER_PROJECT_ROOT/nsconfig.json")

if (nsConfigFile.exists()) {
def nsConfigJsonContent = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))

if (nsConfigJsonContent.appResourcesPath != null) {
pathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(nsConfigJsonContent.appResourcesPath).toAbsolutePath()
} else if (nsConfigJsonContent.appPath != null) {
def pathToApp = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(nsConfigJsonContent.appPath).toAbsolutePath();
pathToAppResources = "$pathToApp/App_Resources"
}
}

return pathToAppResources != null ? pathToAppResources : defaultPathToAppResources
}


def applyPluginsIncludeGradleConfigurations = { ->
def taskNames = project.getGradle().startParameter.taskNames

Expand Down Expand Up @@ -139,7 +160,8 @@ def applyPluginsIncludeGradleConfigurations = { ->
}

def applyAppGradleConfiguration = { ->
def pathToAppGradle = "$rootDir/../../app/App_Resources/Android/app.gradle"
def appResourcesDir = getAppResourcesDirectory()
def pathToAppGradle = "$appResourcesDir/Android/app.gradle"
def appGradle = file(pathToAppGradle)
if (appGradle.exists()) {
println "\t + applying user-defined configuration from ${appGradle}"
Expand Down

0 comments on commit 9edaaaf

Please sign in to comment.