File tree 5 files changed +93
-8
lines changed
5 files changed +93
-8
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,14 @@ task copyFilesToProjectTemeplate {
286
286
from " $TEST_APP_PATH /build.gradle"
287
287
into " $DIST_FRAMEWORK_PATH "
288
288
}
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
+ }
289
297
copy {
290
298
from " $TEST_APP_PATH /gradle"
291
299
into " $DIST_FRAMEWORK_PATH /gradle"
Original file line number Diff line number Diff line change @@ -30,8 +30,9 @@ import java.security.MessageDigest
30
30
31
31
apply plugin : " com.android.application"
32
32
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) {
35
36
apply plugin : ' kotlin-android'
36
37
apply plugin : ' kotlin-android-extensions'
37
38
}
@@ -228,7 +229,7 @@ def setAppIdentifier = { ->
228
229
229
230
android {
230
231
231
- if (useKotlin ) {
232
+ if (enableKotlin ) {
232
233
kotlinOptions {
233
234
jvmTarget = ' 1.8'
234
235
}
@@ -380,7 +381,7 @@ dependencies {
380
381
}
381
382
382
383
def kotlinVersion = computeKotlinVersion()
383
- if (useKotlin ) {
384
+ if (enableKotlin ) {
384
385
implementation " org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion "
385
386
}
386
387
Original file line number Diff line number Diff line change 1
1
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2
2
3
3
buildscript {
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
+
5
13
def computeKotlinVersion = { -> project. hasProperty(" kotlinVersion" ) ? kotlinVersion : " 1.3.41"
6
14
}
7
15
def kotlinVersion = computeKotlinVersion()
16
+
8
17
repositories {
9
18
google()
10
19
jcenter()
11
20
}
12
21
dependencies {
13
22
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 "
17
24
}
18
25
}
19
26
@@ -22,6 +29,16 @@ allprojects {
22
29
google()
23
30
jcenter()
24
31
}
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
+ }
25
42
}
26
43
27
44
task 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