How to suppress gradle warning about Deprecated Gradle features?

3.4k views Asked by At

I am using the latest Gradle v7.2

When I compile it gave me warning

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings

I checked with --warning-mode all, it is only about jcenter deprecation

> Configure project :
The RepositoryHandler.jcenter() method has been deprecated. This is scheduled to be removed in Gradle 8.0. JFrog announced JCenter's sunset in February 2021. Use mavenCentral() instead. Consult the upgrading guide for further information: https://docs.gradle.org/7.2/userguide/upgrading_version_6.html#jcenter_deprecation
        at build_akew6bhcr0m9glzogac5s3m6w$_run_closure1.doCall(/Users/paul.verest/Workspaces/Polkadot/bcd-java/build.gradle:10)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

Now, how can I make gradle ignore exactly one line in build.gradle ( in this case jcenter usage, but may be any ) so that "Deprecated Gradle features were used" would go away,
until new feature is deprecated or my build script got changes?


Yes, this question is not about suppressing compiler output for code,
but for .gradle files produced by gradle.

Not using --warning-mode as it can hide and show all warnings.

P.S. Exactly the case, I have dependency, that are only on jcenter.

3

There are 3 answers

2
Jayan On BEST ANSWER

Sorry - you may not like the answer.

There is no option in gradle (7.2) to suppress specific deprecation. Fixing the build file is going to be cheaper and correct.

0
eskatos On

You can configure the jcenter repository yourself, without using the deprecated helper:

repositories {
    maven {
        name = "jcenter"
        url = uri("https://jcenter.bintray.com/")
    }
}

But given the current state of jcenter (phasing out, regular outages) you'd be in a better situation getting rid of it.

Amongst public central repositories, Maven Central is currently the only sane choice.

Note that gradlePluginPortal() currently proxies jcenter and would make your build also sensitive to jcenter outages.

If you want to limit the impact of these to your build you should leverage repositories content filtering. For example:

repositories {
    maven {
        name = "jcenter"
        url = uri("https://jcenter.bintray.com/")
        content {
            includeGroup("my.only.dependency.from.jcenter")
        }
    }
    mavenCentral()
}

See https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:repository-content-filtering

0
Ebraheem Alrabeea On

Replace the below repo in the Gradle file

jcenter()

With:

mavenCentral() 

Or:

gradlePluginPortal()

That's will suppose that the required dependencies exist in the maven repo, you have to check by making a new build.

Currently, the jcentral() repo is down.