@@ -27,8 +27,13 @@ import java.nio.file.Files
2727import java.nio.file.Paths
2828import java.nio.file.StandardCopyOption
2929import java.security.MessageDigest
30+ import org.gradle.internal.logging.text.StyledTextOutputFactory
31+ import static org.gradle.internal.logging.text.StyledTextOutput.Style
3032
3133apply 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" )
3237
3338def enableKotlin = (project. hasProperty(" useKotlin" ) && project. useKotlin == " true" )
3439
@@ -39,7 +44,7 @@ if (enableKotlin) {
3944
4045def onlyX86 = project. hasProperty(" onlyX86" )
4146if (onlyX86) {
42- println " OnlyX86 build triggered."
47+ outLogger . withStyle( Style.Info ) . println " OnlyX86 build triggered."
4348}
4449
4550// common
@@ -146,15 +151,15 @@ version of the {N} CLI install a previous version of the runtime package - 'tns
146151 def pathToBuildScriptGradle = " $absolutePathToAppResources /Android/buildscript.gradle"
147152 def buildScriptGradle = file(pathToBuildScriptGradle)
148153 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} "
150155 apply from : pathToBuildScriptGradle, to : buildscript
151156 }
152157
153158 nativescriptDependencies. each { dep ->
154159 def pathToPluginBuildScriptGradle = " $rootDir /${ dep.directory} /$PLATFORMS_ANDROID /buildscript.gradle"
155160 def pluginBuildScriptGradle = file(pathToPluginBuildScriptGradle)
156161 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} "
158163 apply from : pathToPluginBuildScriptGradle, to : buildscript
159164 }
160165 }
@@ -172,7 +177,7 @@ def applyBeforePluginGradleConfiguration = { ->
172177 def pathToBeforePluginGradle = " $appResourcesPath /Android/before-plugins.gradle"
173178 def beforePluginGradle = file(pathToBeforePluginGradle)
174179 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} "
176181 apply from : pathToBeforePluginGradle
177182 }
178183}
@@ -182,10 +187,10 @@ def applyAppGradleConfiguration = { ->
182187 def pathToAppGradle = " $appResourcesPath /Android/app.gradle"
183188 def appGradle = file(pathToAppGradle)
184189 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} "
186191 apply from : pathToAppGradle
187192 } 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."
189194 }
190195}
191196
@@ -211,7 +216,7 @@ def getAppIdentifier = { packageJsonMap ->
211216}
212217
213218def setAppIdentifier = { ->
214- println " \t + setting applicationId"
219+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + setting applicationId"
215220 File packageJsonFile = new File (" $USER_PROJECT_ROOT /$PACKAGE_JSON " )
216221
217222 if (packageJsonFile. exists()) {
@@ -339,7 +344,7 @@ dependencies {
339344 androidXMaterialVersion = androidXMaterial
340345 }
341346
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 "
343348
344349 implementation " androidx.multidex:multidex:2.0.1"
345350 implementation " androidx.legacy:legacy-support-v4:$androidXLegacyVersion "
@@ -374,7 +379,7 @@ dependencies {
374379 runtime = " nativescript-regular"
375380 }
376381
377- println " \t + adding nativescript runtime package dependency: $runtime "
382+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + adding nativescript runtime package dependency: $runtime "
378383 project. dependencies. add(" implementation" , [name : runtime, ext : " aar" ])
379384 } else {
380385 implementation project(' :runtime' )
@@ -397,14 +402,14 @@ task addDependenciesFromNativeScriptPlugins {
397402 aarFiles. each { aarFile ->
398403 def length = aarFile. name. length() - 4
399404 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()
401406 project. dependencies. add(" implementation" , [name : fileName, ext : " aar" ])
402407 }
403408
404409 def jarFiles = fileTree(dir : file(" $rootDir /${ dep.directory} /$PLATFORMS_ANDROID " ), include : [" **/*.jar" ])
405410 jarFiles. each { jarFile ->
406411 def jarFileAbsolutePath = jarFile. getAbsolutePath()
407- println " \t + adding jar plugin dependency: $jarFileAbsolutePath "
412+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + adding jar plugin dependency: $jarFileAbsolutePath "
408413 pluginsJarLibraries. add(jarFile. getAbsolutePath())
409414 }
410415
@@ -420,14 +425,14 @@ task addDependenciesFromAppResourcesLibraries {
420425 aarFiles. each { aarFile ->
421426 def length = aarFile. name. length() - 4
422427 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()
424429 project. dependencies. add(" implementation" , [name : fileName, ext : " aar" ])
425430 }
426431
427432 def jarFiles = fileTree(dir : appResourcesLibraries, include : [" **/*.jar" ])
428433 jarFiles. each { jarFile ->
429434 def jarFileAbsolutePath = jarFile. getAbsolutePath()
430- println " \t + adding jar plugin dependency: $jarFileAbsolutePath "
435+ outLogger . withStyle( Style.SuccessHeader ) . println " \t + adding jar plugin dependency: $jarFileAbsolutePath "
431436 pluginsJarLibraries. add(jarFile. getAbsolutePath())
432437 }
433438
@@ -464,7 +469,7 @@ tasks.whenTaskAdded({ org.gradle.api.DefaultTask currentTask ->
464469// /////////////////////////// EXECUTUION PHASE /////////////////////////////////////
465470// //////////////////////////////////////////////////////////////////////////////////
466471
467- task runSbg (type : JavaExec ) {
472+ task runSbg (type : BuildToolTask ) {
468473 dependsOn " collectAllJars"
469474 if (! findProject(' :static-binding-generator' ). is(null )) {
470475 dependsOn ' :static-binding-generator:jar'
@@ -484,6 +489,8 @@ task runSbg(type: JavaExec) {
484489 paramz. add(" -show-deprecation-warnings" )
485490 }
486491
492+ setOutputs outLogger
493+
487494 args paramz
488495
489496 doFirst {
@@ -576,7 +583,7 @@ afterEvaluate { project ->
576583 }
577584 }
578585 } 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"
580587 }
581588 }
582589 }
@@ -695,7 +702,7 @@ task collectAllJars {
695702 }
696703}
697704
698- task buildMetadata (type : JavaExec ) {
705+ task buildMetadata (type : BuildToolTask ) {
699706 if (! findProject(' :android-metadata-generator' ). is(null )) {
700707 dependsOn ' :android-metadata-generator:jar'
701708 }
@@ -749,11 +756,13 @@ task buildMetadata(type: JavaExec) {
749756 workingDir " $BUILD_TOOLS_PATH "
750757 main " -jar"
751758
759+ setOutputs outLogger
760+
752761 args " android-metadata-generator.jar"
753762 }
754763}
755764
756- task generateTypescriptDefinitions (type : JavaExec ) {
765+ task generateTypescriptDefinitions (type : BuildToolTask ) {
757766 if (! findProject(' :dts-generator' ). is(null )) {
758767 dependsOn ' :dts-generator:jar'
759768 }
@@ -784,7 +793,10 @@ task generateTypescriptDefinitions(type: JavaExec) {
784793 new File (" $TYPINGS_PATH " ). mkdirs()
785794
786795 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+
788800 args paramz. toArray()
789801 }
790802}
@@ -807,7 +819,7 @@ static def shouldIncludeDirForTypings(path, includeDirs) {
807819
808820task copyTypings {
809821 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"
811823
812824 copy {
813825 from " $TYPINGS_PATH "
0 commit comments