I work at a big company with a strict policy forbidding the unfiltered use of outside libraries. We have to pull everything from blessed corporate repositories, and not the bare internet, including gradle.org.
Using gradle's original apply plugin syntax, in conjunction with a buildscript block, I can add (blessed) plugins to our repo and use them in builds. In other words:
buildscript {
repositories {
maven { url "https://privaterepo.myemployer.com" }
}
dependencies {
// various dependencies
classpath "org.something:some-plugin:1.0"
...
}
apply plugin: "someplugin"
Instead, I want to be able to use the new plugins DSL, i.e.
plugins {
id 'org.something.some-plugin' version '1.0'
}
(I realize that the private repo url would need to be defined somewhere)
The new plugin syntax always goes to gradle.org and does not appear to have any means to provide an alternate download url. Does anyone know of a way?
I've scrutinized the documentation and the Internet and can't find the answer. Apologies if the answer is completely obvious.
Many Thanks!
It`s need to define pluginRepositories in settings Gradle
https://docs.gradle.org/current/userguide/plugins.html#sec:custom_plugin_repositories
The pluginRepositories {} block may only appear in the settings.gradle file, and must be the first block in the file.
To apply the setting globally, it can be added to USER_HOME/.gradle/init.gradle as follows:
Gradle 3.5 and (presumably) later
Gradle 3.5 has a new (incubating) feature, allowing finer control of the plugin dependency resolution, using the
pluginManagement
DSL:The
repositories
block insidepluginManagement
works the same as thepluginRepositories
block from previous versions.Prior to Gradle 3.5
Prior to Gradle 3.5, you had to define the
pluginRepositories
block in your settings.gradle, as explained in sytolk's answer:The plugin syntax has changed a bit since the latest version of Gradle, and the correct syntax for Gradle 4.x is now:
So, for example, this settings.gradle would use your internal Nexus mirror:
More information can be found in the Gradle plugin documentation.