'When building an Android project, how to disable linting for a specific build variant?

I saw this excellent idea of creating a build variant called staging that is based on release and hence benefits from ART optimisations, but disables minify and shrinkResources for a faster build:

staging {
    initWith release
    minifyEnabled false
    shrinkResources false
}

The problem is that, because it is based on the release variant, it enables lintVitalAnalyseStaging task, which hogs most of the build time.

Is there a way to disable lintVitalAnalyse for just the staging variant without disabling it for other build types?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source