Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nsconfig): read app resources path from nsconfig or default #944

Merged
merged 1 commit into from
Feb 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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