How to make gradle stop getting a not existing jar from a third party maven repo

Failed while running gradle build, gradle tried to download lombok jar from wrong maven repo (a third party one: https://maven.minecraftforge.net) instead of https://mvnrepository.com/.
Here is the build scan: Build Scan® | Gradle Cloud Services
Here is the repo: GitHub - khanshoaib3/minecraft-access: A mod for minecraft java (fabric/forge) that adds accessibility feature

I tried to add

allprojects {
    repositories {
        mavenCentral()
    }
}

into build.gradle under the root but failed.
I’m not familiar with gradle and I can’t figure out how to solve after reading this doc:
https://docs.gradle.org/current/userguide/declaring_repositories.html

So… any hits? Thanks ahead.

FYI:

Caused by: org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'https://maven.minecraftforge.net/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar'.
...
Caused by: java.net.SocketTimeoutException: Read timed out

The main problem is, that this repository is not answering.
It probably is down right now I guess and even dependencies that are required from it will fail.

Besides that allprojects { ... } should not be done as it is highly discouraged bad practice,
Repositories are queried in order.
So the MC repository is probably coming before the mavenCentral() you try to define and thus is not asked in time.

You can use Repository Content Filtering to control which dependencies are resolved from which repositories. But as I said, it will probably not help much as long as you need any dependencies from that repository.

1 Like

Thanks for reply!

I tried to add the following to the top of build.gradle under common sub module but… resulting same error

repositories {
    mavenCentral()
    maven {
        url "https://maven.minecraftforge.net/"
        content {
            excludeGroupByRegex "org\\.projectlombok.*"
        }
    }
}

If the new config works, I though the gradle will at least throw another error (read time out for the next dependency, I guess)?

You say you added this snippet.
So if you did not define that repository before at all, it is probably defined by one of the plugins you apply - which is bad practice too for public plugins.
If that is the case, you just add another repository with the same URL later, but the original repository is still queried first.
You might be able to clear() the repositories first and then add your desired ones.
Or you could instead use the “exclusive content” setup further down in the docs I linked to not say “this repo does not have X” but instead “X should only be taken from that repo”.

1 Like

Thanks! As you said, declaring the following solve the problem:

repositories {
    mavenCentral()
    exclusiveContent {
        forRepository {
            mavenCentral()
        }
        filter {
            includeGroup "org.projectlombok"
        }
    }
}
1 Like