Archinamon / android-gradle-aspectj

gradle plug-in adding supports of AspectJ into Android project
Apache License 2.0
365 stars 58 forks source link

Flag to turn on/off tracing task spend time #76

Closed swapii closed 6 years ago

swapii commented 6 years ago

When I apply plugin com.archinamon:android-gradle-aspectj to my project automatically starts task spent time tracing:

122 actionable tasks: 7 executed, 115 up-to-date
Task spend time:
     58ms       :presentation:compileDebugJavaWithJavac
    330ms       :app:mergeDebugResources
    975ms       :app:processDebugResources
   1229ms       :app:packageDebug

If I correctly analyze source of plugin that behavior implemented in class https://github.com/Archinamon/android-gradle-aspectj/blob/master/android-gradle-aspectj/src/main/kotlin/com/archinamon/api/BuildTimeListener.kt

I don't need this tracing in everytime. Maybe this helpfull when error occurs but not always.

I think plugin should support flag to turn on this tracing and turn it off by default.

Archinamon commented 6 years ago

Hi!

It already has this option: buildTimeLog true // default value in the aspectj extension closure in build.gradle file.

swapii commented 6 years ago

I know about this flag but when I add it to all my modules with aspectj plugin to build.gradle file there is no change. Lines with time still printing:

...

> Task :app:packageRelease
:app:packageRelease spend 2039ms
:app:packageRelease spend 2039ms
:app:packageRelease spend 2039ms
:app:packageRelease spend 2039ms

...

BUILD SUCCESSFUL in 40s
299 actionable tasks: 91 executed, 208 up-to-date
Task spend time:
     51ms       :app:fabricGenerateResourcesDebug
   1958ms       :presentation:packageDebugResources
    306ms       :presentation:mergeDebugResources
    663ms       :presentation:processDebugResources
    508ms       :app:mergeDebugResources
    993ms       :app:processDebugResources
    658ms       :presentation:kaptGenerateStubsDebugKotlin
   8853ms       :presentation:kaptDebugKotlin
    158ms       :presentation:compileDebugKotlin
   2659ms       :presentation:compileDebugJavaWithJavac

...

I doing it right? Or I should write something like

allProjects {
    if (enabledPlugins.contains('com.archinamon.aspectj')) {
        aspectj {
            buildTimeLog false
        }
    }
}

in my root build.gradle file?

swapii commented 6 years ago

Try flag on empty project with applied plugin (no aspects added).

Without flag:

...

> Task :app:processReleaseJavaRes
:app:processReleaseJavaRes spend 0ms

> Task :app:transformResourcesWithMergeJavaResForRelease
:app:transformResourcesWithMergeJavaResForRelease spend 121ms

> Task :app:packageRelease
:app:packageRelease spend 761ms

> Task :app:assembleRelease
:app:assembleRelease spend 1ms

> Task :app:assemble
:app:assemble spend 0ms

BUILD SUCCESSFUL in 10s
55 actionable tasks: 22 executed, 33 up-to-date
Task spend time:
    835ms       :app:compileDebugKotlin
    375ms       :app:compileDebugJavaWithJavac
    581ms       :app:transformClassesWithAspectjForDebug
    311ms       :app:transformClassesWithDexBuilderForDebug
    601ms       :app:transformDexArchiveWithDexMergerForDebug
   1264ms       :app:transformNativeLibsWithMergeJniLibsForDebug
    529ms       :app:transformResourcesWithMergeJavaResForDebug
   1317ms       :app:packageDebug
     83ms       :app:mergeReleaseResources
   1315ms       :app:compileReleaseKotlin
    179ms       :app:compileReleaseJavaWithJavac
    258ms       :app:lintVitalRelease
    133ms       :app:transformClassesWithAspectjForRelease
    134ms       :app:transformClassesWithPreDexForRelease
    328ms       :app:transformDexWithDexForRelease
    122ms       :app:transformNativeLibsWithMergeJniLibsForRelease
    121ms       :app:transformResourcesWithMergeJavaResForRelease
    761ms       :app:packageRelease

With flag (false value):

...

> Task :app:transformNativeLibsWithStripDebugSymbolForRelease
:app:transformNativeLibsWithStripDebugSymbolForRelease spend 2ms

> Task :app:processReleaseJavaRes
:app:processReleaseJavaRes spend 0ms

> Task :app:transformResourcesWithMergeJavaResForRelease
:app:transformResourcesWithMergeJavaResForRelease spend 10ms

> Task :app:packageRelease
:app:packageRelease spend 13ms

> Task :app:assembleRelease
:app:assembleRelease spend 1ms

> Task :app:assemble
:app:assemble spend 0ms

BUILD SUCCESSFUL in 1s
55 actionable tasks: 4 executed, 51 up-to-date
Task spend time:
    251ms       :app:lintVitalRelease

Less lines but :app:lintVitalRelease still printed don't know why.

Archinamon commented 6 years ago

Nope, you're implementing this config in a wrong place. You have to put it into the concrete project's build.gradle file on top level (only if-closures allowed).

Example:

if (isAspectedBuild()) {
    apply plugin: 'com.archinamon.aspectj'

    aspectj {
        buildTimeLog false
    }
}