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:
Plugin resolution rules allow you to modify plugin requests made in
plugins {}
blocks, e.g. changing the requested version or explicitly
specifying the implementation artifact coordinates.To add resolution rules, use the
resolutionStrategy {}
inside the
pluginManagement {}
block:Example 27.6. Plugin resolution strategy.
settings.gradle pluginManagement { resolutionStrategy { eachPlugin { if (requested.id.namespace == 'org.gradle.sample') { useModule('org.gradle.sample:sample-plugins:1.0.0') } } } repositories { maven { url 'maven-repo' } gradlePluginPortal() ivy { url 'ivy-repo' } } }
This tells Gradle to use the specified plugin implementation artifact
instead of using its built-in default mapping from plugin ID to
Maven/Ivy coordinates.The
pluginManagement {}
block may only appear in the settings.gradle
file, and must be the first block in the file. Custom Maven and Ivy
plugin repositories must contain plugin marker artifacts in addition
to the artifacts which actually implement the plugin.
The repositories
block inside pluginManagement
works the same as the pluginRepositories
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 pluginRepositories {} block may only appear in the settings.gradle
file, and must be the first block in the file.pluginRepositories { maven { url 'maven-repo' } gradlePluginPortal() ivy { url 'ivy-repo' } }