11import groovy.json.JsonSlurper
22
3+ apply plugin : ' com.android.library'
4+ apply plugin : ' kotlin-android'
5+ apply plugin : ' kotlin-android-extensions'
6+
7+
38buildscript {
9+ def computeKotlinVersion = { -> project. hasProperty(" kotlinVersion" ) ? kotlinVersion : " 1.4.21" }
10+ def kotlinVersion = computeKotlinVersion()
411 repositories {
512 google()
613 jcenter()
714 }
815 dependencies {
916 classpath ' com.android.tools.build:gradle:{{runtimeAndroidPluginVersion}}'
17+ classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion "
1018
1119 // NOTE: Do not place your application dependencies here; they belong
1220 // in the individual module build.gradle files
1321 }
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+
1470}
1571
1672allprojects {
@@ -25,7 +81,6 @@ allprojects {
2581 }
2682}
2783
28- apply plugin : ' com.android.library'
2984
3085def computeCompileSdkVersion = { -> project. hasProperty(" compileSdk" ) ? compileSdk : 28 }
3186def computeBuildToolsVersion = { ->
@@ -62,35 +117,6 @@ dependencies {
62117 }
63118}
64119
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-
94120def applyBeforePluginGradleConfiguration () {
95121 def appResourcesPath = getAppResourcesPath()
96122 def pathToBeforePluginGradle = " $appResourcesPath /Android/before-plugins.gradle"
0 commit comments