title: How to get a Gradle detached configuration to use a resolution strategy from the dependency-lock plugin?
body: <p>We are using the <a href="https://github.com/nebula-plugins/gradle-dependency-lock-plugin" rel="nofollow">gradle-dependency-lock-plugin</a>. A global.lock file is generated, containing a list of all the dependencies used by our project.</p>
  
  <p>In one of our Gradle tasks, a detached configuration is created and used to resolve an artifact. What I noticed is that it resolves it to the latest version in Nexus, and not to the version in the global.lock file.</p>
  
  <p>For example, global.lock contains some-library-10.0.0-ci.3 but the resolved artifact is at some-library-10.0.0-ci.5.</p>
  
  <p>This appears to be a known problem with detached configurations - they don't use the resolution strategy - as discussed <a href="http://gradle.1045684.n5.nabble.com/Detached-configuration-to-copy-ResolutionStrategy-td5713025.html" rel="nofollow">here</a>.</p>
  
  <p>I was reading the source code of the dependency-lock plugin, and it appears to set the resolutionStrategy for all configurations in DependencyLockPlugin.groovy's applyLock method:</p>
  
  <pre><code>project.configurations.all {
      resolutionStrategy {
          force lockForces.toArray()
      }
  }
  </code></pre>
  
  <p>I was hoping to set the resolution strategy of the detached configuration doing this:</p>
  
  <pre><code>def dep = dependencies.create( elastic( "$notation:$version" ) )
  def detachedConf = configurations.detachedConfiguration( dep ).setTransitive( false )
  detachedConf.resolutionStrategy {
      configurations.all.resolutionStrategy
  }
  def resolvedArtifacts = detachedConf.resolvedConfiguration.resolvedArtifacts
  assert resolvedArtifacts.size() == 1 : 'Only one artifact should be present'
  def resolvedArtifact
  resolvedArtifacts.each { resolvedArtifact = it }
  </code></pre>
  
  <p>However, Gradle complains with:</p>
  
  <pre><code>groovy.lang.MissingPropertyException: Could not find property 'resolutionStrategy' on configuration container.
  </code></pre>
  
  <p>I switched it to use configurations.default.resolutionStrategy and configurations.compile.resolutionStrategy, but in either case it continued to access the latest version from Nexus.</p>
  
  <p>How do I properly set the resolution strategy of the detached configuration so that it uses the same resolution strategy as set by the dependency-lock plugin?</p>