Mark a 3rd party dependency as deprecated in Gradle buid script

Viewed 141

In the build.gradle of my project, I have a dependency added:

dependencies {
    testImplementation 'some-lib'
}

I want to deprecate the usage of this library in the project. I.e., I want it to be there, to compile and run but just warn the user when he's using methods from this library. I can't remove the dependency right away because I need some time to refactor already existing usages. With deprecation, I want to prevent new usages of this lib.

Is it possible to mark the dependency as deprecated in Gradle?

1 Answers

There's no way to mark a dependency as deprecated, but you should be able to add

afterEvaluate {
    if ('some-lib' in configurations.testImplementation.allDependencies.name) {
        logger.warn("**** WARNING: some-lib is deprecated and will be removed.")
    }
}
Related