Thread
#detekt
    i

    iliask

    9 months ago
    Hello everyone, I was wondering: Is it possible to make
    detekt
    (without type resolution at the moment) always run after
    assemble
    tasks automatically, either through a detekt configuration or some gradle magic?
    gammax

    gammax

    9 months ago
    assemble.dependsOn(detektMain)
    should do the job for you 👍
    i

    iliask

    9 months ago
    Thanks for the quick answer! I am working on a multi-module android project and I added a custom
    detektAll
    task in the root
    build.gradle
    tasks.register("detektAll", Detekt) {
    ...
    }
    When adding
    assemble.dependsOn(detektAll)
    in the root
    build.gradle
    then gradle sync fails 🤔
    Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'assemble' for root project
    gammax

    gammax

    9 months ago
    Could not get unknown property ‘assemble’ for root project
    This happens because you don’t have an
    assemble
    task (yet)
    i

    iliask

    9 months ago
    When running
    ./gradlew tasks
    the
    assemble
    task is present. When I add the suggested snippet in the app module
    build.gradle
    then gradle syncs successfully. Perhaps the assemble tasks are not "seen" by the root
    build.gradle
    ?
    gammax

    gammax

    9 months ago
    Perhaps the assemble tasks are not “seen” by the root 
    build.gradle
     ?
    Sort of. The
    assemble
    task are “local” to your subprojects. While I suppose your
    detektAll
    task is declared in the top level build.gradle
    i

    iliask

    9 months ago
    Ok I see it's more of a gradle than a detekt topic. Thanks for your help! Out of curiosity btw are there any plans to "streamline" multi-module support more officially?
    gammax

    gammax

    9 months ago
    You like having a
    detetkAll
    task provided by default?
    i

    iliask

    9 months ago
    Personally I think it would be useful since a lot of android projects are/move towards the multi-module approach. With my "beginner-level" gradle knowledge I needed to connect together some article sources to make it work 😁
    gammax

    gammax

    9 months ago
    The reality is detekt already supports multimodule out of the box. The fact that you want to have a top level
    detektAll
    goes against the Gradle philosophy
    i

    iliask

    9 months ago
    I see perhaps I took the wrong approach with
    detektAll
    . Would you recommend instead to add detekt dependency in every module via
    allprojects {}
    or something else?
    gammax

    gammax

    9 months ago
    If you invoke
    ./gradlew detektMain
    you’re essentially saying to Gradle to invoke
    detetkMain
    on all the subprojects. That should be sufficient to run detekt on all the subprojects (i.e. you don’t need a
    detetkAll
    ). You can specify the dependency between assemble and detektAll a the project level then.
    i

    iliask

    9 months ago
    Ok I will integrate detekt with this approach. Thank you for the help, appreciate it! 🙌
    e

    ephemient

    9 months ago
    note:
    detekt
    is already added as a dependency to the standard
    check
    task, which means if you run either
    gradle check
    or
    gradle build
    , it will also run
    detekt
    gammax

    gammax

    9 months ago
    Yup that’s true, but that’s not the case for Type Resolution tasks