1
1
import groovy.json.JsonSlurper
2
2
3
+ apply plugin : ' com.android.library'
4
+ apply plugin : ' kotlin-android'
5
+ apply plugin : ' kotlin-android-extensions'
6
+
7
+
3
8
buildscript {
9
+ def computeKotlinVersion = { -> project. hasProperty(" kotlinVersion" ) ? kotlinVersion : " 1.4.21" }
10
+ def kotlinVersion = computeKotlinVersion()
4
11
repositories {
5
12
google()
6
13
jcenter()
7
14
}
8
15
dependencies {
9
16
classpath ' com.android.tools.build:gradle:{{runtimeAndroidPluginVersion}}'
17
+ classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion "
10
18
11
19
// NOTE: Do not place your application dependencies here; they belong
12
20
// in the individual module build.gradle files
13
21
}
22
+
23
+ project. ext. getAppResourcesPath = { ->
24
+ def relativePathToApp = " app"
25
+ def relativePathToAppResources
26
+ def absolutePathToAppResources
27
+ def projectRoot = " $rootDir /../../.."
28
+ def nsConfigFile = file(" $projectRoot /nsconfig.json" )
29
+ def nsConfig
30
+
31
+ if (nsConfigFile. exists()) {
32
+ nsConfig = new JsonSlurper (). parseText(nsConfigFile. getText(" UTF-8" ))
33
+ }
34
+
35
+ if (nsConfig != null && nsConfig. appPath != null ){
36
+ relativePathToApp = nsConfig. appPath
37
+ }
38
+
39
+ if (nsConfig != null && nsConfig. appResourcesPath != null ) {
40
+ relativePathToAppResources = nsConfig. appResourcesPath
41
+ } else {
42
+ relativePathToAppResources = " $relativePathToApp /App_Resources"
43
+ }
44
+
45
+ absolutePathToAppResources = java.nio.file.Paths . get(projectRoot). resolve(relativePathToAppResources). toAbsolutePath()
46
+
47
+ project. ext. appResourcesPath = absolutePathToAppResources
48
+
49
+ return absolutePathToAppResources
50
+ }
51
+
52
+ def applyBuildScriptConfigurations = { ->
53
+ def absolutePathToAppResources = getAppResourcesPath()
54
+ def pathToBuildScriptGradle = " $absolutePathToAppResources /Android/buildscript.gradle"
55
+ def buildScriptGradle = file(pathToBuildScriptGradle)
56
+ if (buildScriptGradle. exists()) {
57
+ outLogger. withStyle(Style.SuccessHeader ). println " \t + applying user-defined buildscript from ${ buildScriptGradle} "
58
+ apply from : pathToBuildScriptGradle, to : buildscript
59
+ }
60
+
61
+ def pathToPluginBuildScriptGradle = " $rootDir /buildscript.gradle"
62
+ def pluginBuildScriptGradle = file(pathToPluginBuildScriptGradle)
63
+ if (pluginBuildScriptGradle. exists()) {
64
+ outLogger. withStyle(Style.SuccessHeader ). println " \t + applying user-defined buildscript from dependency ${ pluginBuildScriptGradle} "
65
+ apply from : pathToPluginBuildScriptGradle, to : buildscript
66
+ }
67
+ }
68
+ applyBuildScriptConfigurations()
69
+
14
70
}
15
71
16
72
allprojects {
@@ -25,7 +81,6 @@ allprojects {
25
81
}
26
82
}
27
83
28
- apply plugin : ' com.android.library'
29
84
30
85
def computeCompileSdkVersion = { -> project. hasProperty(" compileSdk" ) ? compileSdk : 28 }
31
86
def computeBuildToolsVersion = { ->
@@ -62,35 +117,6 @@ dependencies {
62
117
}
63
118
}
64
119
65
- def getAppResourcesPath () {
66
- def relativePathToApp = " app"
67
- def relativePathToAppResources
68
- def absolutePathToAppResources
69
- def projectRoot = " $rootDir /../../.."
70
- def nsConfigFile = file(" $projectRoot /nsconfig.json" )
71
- def nsConfig
72
-
73
- if (nsConfigFile. exists()) {
74
- nsConfig = new JsonSlurper (). parseText(nsConfigFile. getText(" UTF-8" ))
75
- }
76
-
77
- if (nsConfig != null && nsConfig. appPath != null ){
78
- relativePathToApp = nsConfig. appPath
79
- }
80
-
81
- if (nsConfig != null && nsConfig. appResourcesPath != null ) {
82
- relativePathToAppResources = nsConfig. appResourcesPath
83
- } else {
84
- relativePathToAppResources = " $relativePathToApp /App_Resources"
85
- }
86
-
87
- absolutePathToAppResources = java.nio.file.Paths . get(projectRoot). resolve(relativePathToAppResources). toAbsolutePath()
88
-
89
- project. ext. appResourcesPath = absolutePathToAppResources
90
-
91
- return absolutePathToAppResources
92
- }
93
-
94
120
def applyBeforePluginGradleConfiguration () {
95
121
def appResourcesPath = getAppResourcesPath()
96
122
def pathToBeforePluginGradle = " $appResourcesPath /Android/before-plugins.gradle"
0 commit comments