1

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.

Paul Verest
  • 60,022
  • 51
  • 208
  • 332
  • 1
    jcenter is dead now... why not just remove it from the build script? – tim_yates Sep 10 '21 at 17:23
  • 1
    @tim_yates: is it possible that some library(or version) present in jcenter not available else where? In that case replacing jcenter with mavenCentral needs more work. (I agree fixing this right away is way cheaper) – Jayan Sep 10 '21 at 18:09
  • Maybe, but the jcenter repository got shut down in June this year, so they'll be already broken – tim_yates Sep 10 '21 at 18:14
  • 1
    No - an existing build should not fail. JFrog is keeping the repo read only. All build worked with it will work forever-- https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/ (They listened to community and changed the strategy ) – Jayan Sep 10 '21 at 18:16
  • I get a 403 for every jar I try... IE https://jcenter.bintray.com/net/rubygrapefruit/ansi-control-sequence-util/0.2/ansi-control-sequence-util-0.2.jar – tim_yates Sep 10 '21 at 18:20
  • 1
    P.S. Exactly the case, I have dependency, that are only on jcenter. Bintray always 403, JCenter works in readonly mode – Paul Verest Sep 10 '21 at 21:03
  • I am keen to know which library and versions giving 403. What would have been your action if they actually stopped the service? – Jayan Sep 11 '21 at 16:11
  • The original question is about gradle built-in linter, and how to reduce noise during build. What and when is going to happen with jcenter are speculations. Life teaches to treat problem that we cannot influence, when they happen. If you want to know more ask question and link here. – Paul Verest Sep 13 '21 at 01:40
  • 2
    @tim_yates : You are probably checking from browser which is getting handled differently. `curl -O https://jcenter.bintray.com/net/rubygrapefruit/ansi-control-sequence-util/0.2/ansi-control-sequence-util-0.2.jar` worked fine ; so is from gradle build. (This is a good strategy from jfrog to discourage users but still honor all existing build files) – Jayan Sep 13 '21 at 17:26
  • @tim_yates : and trying to fetch .3 does fail with `404 (Could not find resource)` - this is newer version released after the freeze. – Jayan Sep 13 '21 at 17:33

3 Answers3

3

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.

Jayan
  • 18,003
  • 15
  • 89
  • 143
0

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.

Ebraheem Alrabeea
  • 2,130
  • 3
  • 23
  • 42
0

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

eskatos
  • 4,174
  • 2
  • 40
  • 42