'Gradle plugin dependency exists but isn't found during the build

It seems like what I have is correct, but Gradle is still not finding the plugin.

My plugins clause looks like:

plugins {
    id "io.codearte.nexus-staging" version "0.8.0"
}

The build error looks like:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/local/MAGICLEAP/doprea/development/java/JenkinsPipelineUnit-1.1/build.gradle' line: 4

* What went wrong:
Plugin [id: 'io.codearte.nexus-staging', version: '0.8.0'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'io.codearte.nexus-staging:io.codearte.nexus-staging.gradle.plugin:0.8.0')
  Searched in the following repositories:
    Gradle Central Plugin Repository

However, the CR appears to have it:

https://plugins.gradle.org/plugin/io.codearte.nexus-staging/0.8.0

..and the dependency clause provided there is identical to what I already have.

Am I missing something?



Solution 1:[1]

The plugin page states two ways of including the plugin (https://plugins.gradle.org/plugin/io.codearte.nexus-staging#new-plugin-mechanism-info). The one for plugins DSL for Gradle 2.1 and the one for use in older Gradle versions or where dynamic configuration is required. The Gradle plugins DSL version has some constraints and did not work in any case, e.g.

  1. Can only be used in build scripts.
  2. Cannot be used in conjunction with subprojects {}, allprojects {} etc.
  3. The plugins {} block must also be a top level statement in the buildscript

If the plugins DSL version did not work for you should use the other way of including it.

Solution 2:[2]

Adding

rootProject.buildFileName = 'build.gradle.kts'

in settings.gradle file on the 1st line should help you.

@Reference: reference link

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mascha
Solution 2