Search code examples
androidgradlelintandroid-lint

Android lint: How to disable "NewerVersionAvailable" check for testCompile dependencies?


I'm using NewerVersionAvailable lint check to determine newer dependencies versions. But it looks like that this check is useful only for implementation dependencies. I think we don't need to update junit anytime soon. How to disable this check for separate dependency type? It is boring to add //noinspection to each testImplementation dependency. Example given:

dependencies {

    // should warn
    implementation 'com.android.support:support-annotations:25.0.0'

    // shouldn't warn
    testImplementation 'junit:junit:4.12'
}

Solution

  • One should better disable the check for individual dependencies, simply because then one would still be notified of any further outdated libraries:

    <issue id="NewerVersionAvailable">
        <ignore regexp="junit:junit*"/>
    </issue>
    

    With such a pattern: junit:junit* one can ignore individual dependencies - and one can ignore whole dependency-groups with such a pattern: junit:*.

    This still needs to be combined with //noinspection GradleDependency, because lint and the IDE's code-inspection are not the same thing.