1+ import groovy.json.JsonSlurper
12
23buildscript {
34 repositories {
@@ -32,6 +33,8 @@ def computeBuildToolsVersion = { ->
3233}
3334
3435android {
36+ applyBeforePluginGradleConfiguration()
37+
3538 compileSdkVersion computeCompileSdkVersion()
3639 buildToolsVersion computeBuildToolsVersion()
3740
@@ -50,3 +53,42 @@ dependencies {
5053 compileOnly " com.android.support:support-v4:$supportVer "
5154 compileOnly " com.android.support:appcompat-v7:$supportVer "
5255}
56+
57+ def getAppResourcesPath () {
58+ def relativePathToApp = " app"
59+ def relativePathToAppResources
60+ def absolutePathToAppResources
61+ def projectRoot = " $rootDir /../../.."
62+ def nsConfigFile = file(" $projectRoot /nsconfig.json" )
63+ def nsConfig
64+
65+ if (nsConfigFile. exists()) {
66+ nsConfig = new JsonSlurper (). parseText(nsConfigFile. getText(" UTF-8" ))
67+ }
68+
69+ if (nsConfig != null && nsConfig. appPath != null ){
70+ relativePathToApp = nsConfig. appPath
71+ }
72+
73+ if (nsConfig != null && nsConfig. appResourcesPath != null ) {
74+ relativePathToAppResources = nsConfig. appResourcesPath
75+ } else {
76+ relativePathToAppResources = " $relativePathToApp /App_Resources"
77+ }
78+
79+ absolutePathToAppResources = java.nio.file.Paths . get(projectRoot). resolve(relativePathToAppResources). toAbsolutePath()
80+
81+ project. ext. appResourcesPath = absolutePathToAppResources
82+
83+ return absolutePathToAppResources
84+ }
85+
86+ def applyBeforePluginGradleConfiguration () {
87+ def appResourcesPath = getAppResourcesPath()
88+ def pathToBeforePluginGradle = " $appResourcesPath /Android/before-plugins.gradle"
89+ def beforePluginGradle = file(pathToBeforePluginGradle)
90+ if (beforePluginGradle. exists()) {
91+ println " \t + applying user-defined configuration from ${ beforePluginGradle} "
92+ apply from : pathToBeforePluginGradle
93+ }
94+ }
0 commit comments