@@ -27,8 +27,13 @@ import java.nio.file.Files
27
27
import java.nio.file.Paths
28
28
import java.nio.file.StandardCopyOption
29
29
import java.security.MessageDigest
30
+ import org.gradle.internal.logging.text.StyledTextOutputFactory
31
+ import static org.gradle.internal.logging.text.StyledTextOutput.Style
30
32
31
33
apply plugin : " com.android.application"
34
+ apply from : " gradle-helpers/BuildToolTask.gradle"
35
+ apply from : " gradle-helpers/CustomExecutionLogger.gradle"
36
+ def outLogger = services. get(StyledTextOutputFactory ). create(" colouredOutputLogger" )
32
37
33
38
def enableKotlin = (project. hasProperty(" useKotlin" ) && project. useKotlin == " true" )
34
39
@@ -39,7 +44,7 @@ if (enableKotlin) {
39
44
40
45
def onlyX86 = project. hasProperty(" onlyX86" )
41
46
if (onlyX86) {
42
- println " OnlyX86 build triggered."
47
+ outLogger . withStyle( Style.Info ) . println " OnlyX86 build triggered."
43
48
}
44
49
45
50
// common
@@ -146,15 +151,15 @@ version of the {N} CLI install a previous version of the runtime package - 'tns
146
151
def pathToBuildScriptGradle = " $absolutePathToAppResources /Android/buildscript.gradle"
147
152
def buildScriptGradle = file(pathToBuildScriptGradle)
148
153
if (buildScriptGradle. exists()) {
149
- println " \t + applying user-defined buildscript from ${ buildScriptGradle} "
154
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + applying user-defined buildscript from ${ buildScriptGradle} "
150
155
apply from : pathToBuildScriptGradle, to : buildscript
151
156
}
152
157
153
158
nativescriptDependencies. each { dep ->
154
159
def pathToPluginBuildScriptGradle = " $rootDir /${ dep.directory} /$PLATFORMS_ANDROID /buildscript.gradle"
155
160
def pluginBuildScriptGradle = file(pathToPluginBuildScriptGradle)
156
161
if (pluginBuildScriptGradle. exists()) {
157
- println " \t + applying user-defined buildscript from dependency ${ pluginBuildScriptGradle} "
162
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + applying user-defined buildscript from dependency ${ pluginBuildScriptGradle} "
158
163
apply from : pathToPluginBuildScriptGradle, to : buildscript
159
164
}
160
165
}
@@ -172,7 +177,7 @@ def applyBeforePluginGradleConfiguration = { ->
172
177
def pathToBeforePluginGradle = " $appResourcesPath /Android/before-plugins.gradle"
173
178
def beforePluginGradle = file(pathToBeforePluginGradle)
174
179
if (beforePluginGradle. exists()) {
175
- println " \t + applying user-defined configuration from ${ beforePluginGradle} "
180
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + applying user-defined configuration from ${ beforePluginGradle} "
176
181
apply from : pathToBeforePluginGradle
177
182
}
178
183
}
@@ -182,10 +187,10 @@ def applyAppGradleConfiguration = { ->
182
187
def pathToAppGradle = " $appResourcesPath /Android/app.gradle"
183
188
def appGradle = file(pathToAppGradle)
184
189
if (appGradle. exists()) {
185
- println " \t + applying user-defined configuration from ${ appGradle} "
190
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + applying user-defined configuration from ${ appGradle} "
186
191
apply from : pathToAppGradle
187
192
} else {
188
- println " \t + couldn't load user-defined configuration from ${ appGradle} . File doesn't exist."
193
+ outLogger . withStyle( Style.Info ) . println " \t + couldn't load user-defined configuration from ${ appGradle} . File doesn't exist."
189
194
}
190
195
}
191
196
@@ -211,7 +216,7 @@ def getAppIdentifier = { packageJsonMap ->
211
216
}
212
217
213
218
def setAppIdentifier = { ->
214
- println " \t + setting applicationId"
219
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + setting applicationId"
215
220
File packageJsonFile = new File (" $USER_PROJECT_ROOT /$PACKAGE_JSON " )
216
221
217
222
if (packageJsonFile. exists()) {
@@ -339,7 +344,7 @@ dependencies {
339
344
androidXMaterialVersion = androidXMaterial
340
345
}
341
346
342
- println " \t + using android X library androidx.legacy:legacy-support-v4:$androidXLegacyVersion "
347
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + using android X library androidx.legacy:legacy-support-v4:$androidXLegacyVersion "
343
348
344
349
implementation " androidx.multidex:multidex:2.0.1"
345
350
implementation " androidx.legacy:legacy-support-v4:$androidXLegacyVersion "
@@ -374,7 +379,7 @@ dependencies {
374
379
runtime = " nativescript-regular"
375
380
}
376
381
377
- println " \t + adding nativescript runtime package dependency: $runtime "
382
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + adding nativescript runtime package dependency: $runtime "
378
383
project. dependencies. add(" implementation" , [name : runtime, ext : " aar" ])
379
384
} else {
380
385
implementation project(' :runtime' )
@@ -397,14 +402,14 @@ task addDependenciesFromNativeScriptPlugins {
397
402
aarFiles. each { aarFile ->
398
403
def length = aarFile. name. length() - 4
399
404
def fileName = aarFile. name[0 .. < length]
400
- println " \t + adding aar plugin dependency: " + aarFile. getAbsolutePath()
405
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + adding aar plugin dependency: " + aarFile. getAbsolutePath()
401
406
project. dependencies. add(" implementation" , [name : fileName, ext : " aar" ])
402
407
}
403
408
404
409
def jarFiles = fileTree(dir : file(" $rootDir /${ dep.directory} /$PLATFORMS_ANDROID " ), include : [" **/*.jar" ])
405
410
jarFiles. each { jarFile ->
406
411
def jarFileAbsolutePath = jarFile. getAbsolutePath()
407
- println " \t + adding jar plugin dependency: $jarFileAbsolutePath "
412
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + adding jar plugin dependency: $jarFileAbsolutePath "
408
413
pluginsJarLibraries. add(jarFile. getAbsolutePath())
409
414
}
410
415
@@ -420,14 +425,14 @@ task addDependenciesFromAppResourcesLibraries {
420
425
aarFiles. each { aarFile ->
421
426
def length = aarFile. name. length() - 4
422
427
def fileName = aarFile. name[0 .. < length]
423
- println " \t + adding aar library dependency: " + aarFile. getAbsolutePath()
428
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + adding aar library dependency: " + aarFile. getAbsolutePath()
424
429
project. dependencies. add(" implementation" , [name : fileName, ext : " aar" ])
425
430
}
426
431
427
432
def jarFiles = fileTree(dir : appResourcesLibraries, include : [" **/*.jar" ])
428
433
jarFiles. each { jarFile ->
429
434
def jarFileAbsolutePath = jarFile. getAbsolutePath()
430
- println " \t + adding jar plugin dependency: $jarFileAbsolutePath "
435
+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + adding jar plugin dependency: $jarFileAbsolutePath "
431
436
pluginsJarLibraries. add(jarFile. getAbsolutePath())
432
437
}
433
438
@@ -464,7 +469,7 @@ tasks.whenTaskAdded({ org.gradle.api.DefaultTask currentTask ->
464
469
// /////////////////////////// EXECUTUION PHASE /////////////////////////////////////
465
470
// //////////////////////////////////////////////////////////////////////////////////
466
471
467
- task runSbg (type : JavaExec ) {
472
+ task runSbg (type : BuildToolTask ) {
468
473
dependsOn " collectAllJars"
469
474
if (! findProject(' :static-binding-generator' ). is(null )) {
470
475
dependsOn ' :static-binding-generator:jar'
@@ -484,6 +489,8 @@ task runSbg(type: JavaExec) {
484
489
paramz. add(" -show-deprecation-warnings" )
485
490
}
486
491
492
+ setOutputs outLogger
493
+
487
494
args paramz
488
495
489
496
doFirst {
@@ -576,7 +583,7 @@ afterEvaluate { project ->
576
583
}
577
584
}
578
585
} else {
579
- println " WARNING: Folder ${ jarDir.path} does not exists, the dependent project's classes won't be included in the metadata"
586
+ outLogger . withStyle( Style.Info ) . println " WARNING: Folder ${ jarDir.path} does not exists, the dependent project's classes won't be included in the metadata"
580
587
}
581
588
}
582
589
}
@@ -695,7 +702,7 @@ task collectAllJars {
695
702
}
696
703
}
697
704
698
- task buildMetadata (type : JavaExec ) {
705
+ task buildMetadata (type : BuildToolTask ) {
699
706
if (! findProject(' :android-metadata-generator' ). is(null )) {
700
707
dependsOn ' :android-metadata-generator:jar'
701
708
}
@@ -749,11 +756,13 @@ task buildMetadata(type: JavaExec) {
749
756
workingDir " $BUILD_TOOLS_PATH "
750
757
main " -jar"
751
758
759
+ setOutputs outLogger
760
+
752
761
args " android-metadata-generator.jar"
753
762
}
754
763
}
755
764
756
- task generateTypescriptDefinitions (type : JavaExec ) {
765
+ task generateTypescriptDefinitions (type : BuildToolTask ) {
757
766
if (! findProject(' :dts-generator' ). is(null )) {
758
767
dependsOn ' :dts-generator:jar'
759
768
}
@@ -784,7 +793,10 @@ task generateTypescriptDefinitions(type: JavaExec) {
784
793
new File (" $TYPINGS_PATH " ). mkdirs()
785
794
786
795
logger. info(" Task generateTypescriptDefinitions: Call dts-generator.jar with arguments: " + paramz. toString(). replaceAll(' ,' , ' ' ))
787
- println " Task generateTypescriptDefinitions: Call dts-generator.jar with arguments: " + paramz. toString(). replaceAll(' ,' , ' ' )
796
+ outLogger. withStyle(Style.SuccessHeader ). println " Task generateTypescriptDefinitions: Call dts-generator.jar with arguments: " + paramz. toString(). replaceAll(' ,' , ' ' )
797
+
798
+ setOutputs outLogger
799
+
788
800
args paramz. toArray()
789
801
}
790
802
}
@@ -807,7 +819,7 @@ static def shouldIncludeDirForTypings(path, includeDirs) {
807
819
808
820
task copyTypings {
809
821
doLast {
810
- println " Copied generated typings to application root level. Make sure to import android.d.ts in reference.d.ts"
822
+ outLogger . withStyle( Style.Info ) . println " Copied generated typings to application root level. Make sure to import android.d.ts in reference.d.ts"
811
823
812
824
copy {
813
825
from " $TYPINGS_PATH "
0 commit comments