title: Gradle never resolves Artifactory before JCenter repository for dependencies
body: <p>I have a Gradle build script for a Java project. I have set up an internal Artifactory repository as a remote for the project's dependencies.</p>
  
  <p><em>When the project is compiling, I want Gradle to first go to Artifactory and request; if it fails there, it should next try JCenter as a backup.</em></p>
  
  <p>I am using the Gradle Artifactory plugin, v3.1.1, in Gradle 2.8. The plugin defines its <code>contextUrl</code>, <code>publish</code> repo, and <code>resolve</code> repo in a closure:</p>
  
  <pre><code>artifactory {
      contextUrl = "${artifactoryContextUrl}"
      publish {
          repository {
              repoKey = 'Release'
              username = "${artifactoryUser}"
              password = "${artifactoryPassword}"
              maven = true
          }
      }
      resolve {
          repository {
              repoKey = 'repo'
              username = "${artifactoryUser}"
              password = "${artifactoryPassword}"
              maven = true
          }
      }
  }
  </code></pre>
  
  <p>Both the buildscript and the project define their repositories:</p>
  
  <pre><code>buildscript {
      repositories {
          maven {
              name 'Artifactory'
              url "${artifactoryContextUrl}repo"
              credentials {
                  username = "${artifactoryUser}"
                  password = "${artifactoryPassword}"
              }
          }
          jcenter()
      }
  }
  
  repositories {
      maven {
          name 'Artifactory'
          url "${artifactoryContextUrl}repo"
          credentials {
              username = "${artifactoryUser}"
              password = "${artifactoryPassword}"
          }
      }
      jcenter()
  }
  </code></pre>
  
  <p>I have had to resort to these duplicate statements that repeatedly define the Artifactory repo, as I can't seem to find a way to define and place the <code>artifactory</code> closure in the build script so that Gradle refers to this defined <code>resolve</code> repo before trying JCenter.</p>
  
  <p>Preferably, the solution would address this duplicate definition in both the <code>buildscript</code> and <code>repositories</code> closures, but it's seems unlikely that I could refer to the properties inside the <code>artifactory</code> closure before the Gradle-Artifactory plugin is installed.</p>