Prevent Maven dependencies for project retrieved from plugins.gradle.org (before checking configured repositories)

I was suprised today by Gradle fetching dependencies for my Java/Groovy project (not the buildscript) from plugins.gradle.org instead of from the repositories configured in the repositories closure.

Is this new, that the Gradle plugins Maven repository mirrors Maven Central? Otherwise I can’t explain the change in behavior.

Usually this would not be a problem, but all my projects using ‘javax.media:jai_core:1.1.3’ as dependency are failing, because there the repository order matters for that one, as the JAR cannot be retrieved from Maven Central or the Gradle Plugins repository, as they either contain only the POM or an empty JAR (because of license restrictions).

How can I prevent the dependencies from being retrieved from plugins.gradle.org/m2 before my configured repositories are checked?

In my specific case I can see the POM being downloaded from plugins.gradle.org:

Download https://plugins.gradle.org/m2/javax/media/jai_core/1.1.3/jai_core-1.1.3.pom

At the end, there is this error because the JAR can’t be retrieved from there:

* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not find jai_core.jar (javax.media:jai_core:1.1.3).
  Searched in the following locations:
      https://plugins.gradle.org/m2/javax/media/jai_core/1.1.3/jai_core-1.1.3.jar

The dependency is declared in the normal compile configuration, several Maven repositories to be used are configured for the project, and those do not include the Gradle plugins repository (if this is not explicitly done using the plugins {…} closure, but I would assume that this affects the repositories used for the buildscript only).
Tested with Gradle 2.11 (which the build was running without a problem before today) and Gradle 2.14.1.

After some more digging found out that the Gradle plugin repository seems to be added by a plugin that I updated - should have looked into that before. Just didn’t think any plugin would be so bold to mess with my project repositories :wink:

If anyone else is having a similar issue using the Gradle Docker plugin, see the corresponding plugin issue here for a workaround.