1
+ import groovy.json.JsonSlurper
1
2
2
3
buildscript {
3
4
repositories {
@@ -32,6 +33,8 @@ def computeBuildToolsVersion = { ->
32
33
}
33
34
34
35
android {
36
+ applyBeforePluginGradleConfiguration()
37
+
35
38
compileSdkVersion computeCompileSdkVersion()
36
39
buildToolsVersion computeBuildToolsVersion()
37
40
@@ -50,3 +53,42 @@ dependencies {
50
53
compileOnly " com.android.support:support-v4:$supportVer "
51
54
compileOnly " com.android.support:appcompat-v7:$supportVer "
52
55
}
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