File tree Expand file tree Collapse file tree 5 files changed +93
-8
lines changed Expand file tree Collapse file tree 5 files changed +93
-8
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,14 @@ task copyFilesToProjectTemeplate {
286286 from " $TEST_APP_PATH /build.gradle"
287287 into " $DIST_FRAMEWORK_PATH "
288288 }
289+ copy {
290+ from " $TEST_APP_PATH /paths.gradle"
291+ into " $DIST_FRAMEWORK_PATH "
292+ }
293+ copy {
294+ from " $TEST_APP_PATH /user_properties_reader.gradle"
295+ into " $DIST_FRAMEWORK_PATH "
296+ }
289297 copy {
290298 from " $TEST_APP_PATH /gradle"
291299 into " $DIST_FRAMEWORK_PATH /gradle"
Original file line number Diff line number Diff line change @@ -30,8 +30,9 @@ import java.security.MessageDigest
3030
3131apply plugin : " com.android.application"
3232
33- def useKotlin = project. hasProperty(" useKotlin" ) && project. ext. useKotlin== " true"
34- if (useKotlin) {
33+ def enableKotlin = (project. hasProperty(" useKotlin" ) && project. useKotlin == " true" )
34+
35+ if (enableKotlin) {
3536 apply plugin : ' kotlin-android'
3637 apply plugin : ' kotlin-android-extensions'
3738}
@@ -228,7 +229,7 @@ def setAppIdentifier = { ->
228229
229230android {
230231
231- if (useKotlin ) {
232+ if (enableKotlin ) {
232233 kotlinOptions {
233234 jvmTarget = ' 1.8'
234235 }
@@ -380,7 +381,7 @@ dependencies {
380381 }
381382
382383 def kotlinVersion = computeKotlinVersion()
383- if (useKotlin ) {
384+ if (enableKotlin ) {
384385 implementation " org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion "
385386 }
386387
Original file line number Diff line number Diff line change 11// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
33buildscript {
4- def useKotlin = project. hasProperty(" useKotlin" ) && project. ext. useKotlin == " true"
4+
5+ def initialize = { ->
6+ def userDir = " ${ rootProject.projectDir} /../.."
7+ apply from : " $rootDir /user_properties_reader.gradle"
8+ apply from : " $rootDir /paths.gradle"
9+ rootProject. ext. userDefinedGradleProperties = getUserProperties(" ${ getAppResourcesPath(userDir)} /Android" )
10+ }
11+ initialize()
12+
513 def computeKotlinVersion = { -> project. hasProperty(" kotlinVersion" ) ? kotlinVersion : " 1.3.41"
614 }
715 def kotlinVersion = computeKotlinVersion()
16+
817 repositories {
918 google()
1019 jcenter()
1120 }
1221 dependencies {
1322 classpath ' com.android.tools.build:gradle:3.5.0'
14- if (useKotlin) {
15- classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion "
16- }
23+ classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion "
1724 }
1825}
1926
@@ -22,6 +29,16 @@ allprojects {
2229 google()
2330 jcenter()
2431 }
32+ beforeEvaluate { project ->
33+ if (rootProject. hasProperty(" userDefinedGradleProperties" )) {
34+ rootProject. ext. userDefinedGradleProperties. each { entry ->
35+ def propertyName = entry. getKey()
36+ def propertyValue = entry. getValue()
37+ project. ext. set(propertyName, propertyValue)
38+ }
39+ }
40+
41+ }
2542}
2643
2744task clean (type : Delete ) {
Original file line number Diff line number Diff line change 1+ import groovy.json.JsonSlurper
2+
3+ ext. getAppPath = { userDir ->
4+ def relativePathToApp = " app"
5+ def nsConfigFile = file(" $userDir /nsconfig.json" )
6+ def nsConfig
7+
8+ if (nsConfigFile. exists()) {
9+ nsConfig = new JsonSlurper (). parseText(nsConfigFile. getText(" UTF-8" ))
10+ }
11+
12+ if (nsConfig != null && nsConfig. appPath != null ) {
13+ relativePathToApp = nsConfig. appPath
14+ }
15+
16+ return java.nio.file.Paths . get(userDir). resolve(relativePathToApp). toAbsolutePath()
17+ }
18+
19+ ext. getAppResourcesPath = { userDir ->
20+ def relativePathToAppResources
21+ def absolutePathToAppResources
22+ def nsConfigFile = file(" $userDir /nsconfig.json" )
23+ def nsConfig
24+
25+ if (nsConfigFile. exists()) {
26+ nsConfig = new JsonSlurper (). parseText(nsConfigFile. getText(" UTF-8" ))
27+ }
28+
29+ if (nsConfig != null && nsConfig. appResourcesPath != null ) {
30+ relativePathToAppResources = nsConfig. appResourcesPath
31+ absolutePathToAppResources = java.nio.file.Paths . get(userDir). resolve(relativePathToAppResources). toAbsolutePath()
32+ } else {
33+ absolutePathToAppResources = " ${ getAppPath(userDir)} /App_Resources"
34+ }
35+
36+ return absolutePathToAppResources
37+ }
Original file line number Diff line number Diff line change 1+ def GRADLE_PROPERTIES_FILENAME = " gradle.properties"
2+
3+ def getFile = { dir , filename ->
4+ File file = new File (" $dir $File . separator $filename " )
5+ file?. exists() ? file : null
6+ }
7+
8+ def getPropertyFile = { dir ->
9+ return getFile(dir, GRADLE_PROPERTIES_FILENAME )
10+ }
11+
12+ ext. getUserProperties = { dir ->
13+ def file = getPropertyFile(dir)
14+ if (! file) {
15+ return null
16+ }
17+
18+ Properties properties = new Properties ()
19+ properties. load(file. newInputStream())
20+
21+ return properties
22+ }
You can’t perform that action at this time.
0 commit comments