title: Unable to resolve a plugin using the new plugin mechanism in Gradle
body: <p>While trying to upgrade some of our scripts to Gradle 4.0.1 on of the plugins we are using is failing and I thought of fixing that plugin first. The plugin is a third party open source project.</p>
  
  <p>So I have cloned the project and tried to compile it. However it fails with following message: </p>
  
  <pre><code>c:\source\gradle-xld-plugin&gt;gradlew build
  
  FAILURE: Build failed with an exception.
  
  * Where:
  Build file 'C:\source\gradle-xld-plugin\build.gradle' line: 2
  
  * What went wrong:
  Plugin [id: 'com.gradle.plugin-publish', version: '0.9.7'] was not found in 
  any of the following sources:
  
  - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  - maven(https://artifactory/java-v) (Could not resolve plugin artifact 'com.gradle.plugin-publish:com.gradle.plugin-publish.gradle.plugin:0.9.7')
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --
  debug option to get more log output.
  
  BUILD FAILED in 0s
  </code></pre>
  
  <p>The build.gradle script for the plugin starts like this:</p>
  
  <pre><code>plugins {
    id "com.gradle.plugin-publish" version "0.9.7"
    id "com.github.hierynomus.license" version "0.11.0"
    id 'nebula.nebula-release' version '4.0.1'
    id "com.jfrog.bintray" version "1.7.3"
  }
  </code></pre>
  
  <p>In addition to this the company policy dictates we have to go through an internal artifactory server, so following has been added to the settings.gradle file:</p>
  
  <pre><code>pluginManagement {
      repositories {
          maven {
              url "https://artifactory/java-v"
          }
      }
  }
  </code></pre>
  
  <p>The jar file exists at following location: <a href="https://artifactory/java-v/com/gradle/publish/plugin-publish-plugin/0.9.7/plugin-publish-plugin-0.9.7.jar" rel="noreferrer">https://artifactory/java-v/com/gradle/publish/plugin-publish-plugin/0.9.7/plugin-publish-plugin-0.9.7.jar</a></p>
  
  <p>but when I look at the error message I am a little puzzled that it says that it cannot find com.gradle.plugin-publish:com.gradle.plugin-publish.gradle.plugin:0.9.7. 
  It seems to have suffixed the id with .gradle.plugin. </p>
  
  <p>Does anyone know whether I am looking at the wrong location or how come it is suffixing the id with .gradle.plugin. And shouldn't it look at a location that has the GAV like this: com.gradle.plugin-publish:com.gradle.plugin-publish:0.9.7?</p>
  
  <p>And does anyone know about how the resolution mechanism for the new plugin mechanism in Gradle works.</p>
  
  <p>Thanks in advance</p>
  
  <p><strong>Edit</strong>
  Thanks to Mateusz Chrzaszcz I was able to progress.</p>
  
  <p>The only caveat I have with the solution is that it seems like a workaround rather than a solution. But it works!</p>
  
  <p>In addition to his solution you had to resolve the plugins. I was able to hack my way to actually resolve the appropriate names.</p>
  
  <p>In order to do so one has to do as follows:</p>
  
  <ol>
  <li>In a webbrowser go for the plugin: id "com.github.hierynomus.license" version "0.11.0" go to following URL: <a href="https://plugins.gradle.org/api/gradle/4.0.1/plugin/use/com.github.hierynomus.license/0.11.0" rel="noreferrer">https://plugins.gradle.org/api/gradle/4.0.1/plugin/use/com.github.hierynomus.license/0.11.0</a></li>
  <li>The json returned contains the GAV needed in the useModule call. Use that</li>
  </ol>
  
  <p>The following serves as an example:</p>
  
  <pre><code>resolutionStrategy {
      eachPlugin {
          if (requested.id.namespace == 'com.gradle' &amp;&amp; requested.id.name == 'plugin-publish') {
              useModule('com.gradle.publish:plugin-publish-plugin:0.9.7')
          } else if(requested.id.namespace == 'com.github.hierynomus' &amp;&amp; requested.id.name == 'license') {
              useModule('nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0')
          }
      }
  }
  </code></pre>