How to specify a dependency on an expicit artifact (or configuration) of a project

In order to specify a project dependency to a particular configuration you can use the following notation:

project(path: ‘:myproject’, configuration: ‘webFrontEnd’)

How can I apply the above when implementing a variation on something similar to gradle-elasticdependencies (https://github.com/stackmagic/gradle-elasticdependencies/blob/master/src/main/groovy/net/swisstech/gradle/elasticdependencies/ElasticDependenciesPlugin.groovy).

In the example below, I want to specify a specific project configuration. I just cannot figure how to use the API to accomplish it. This line is the problem. This line is the not correct usage of the API - just cannot figure out the correct API call(s).

projectDependency = project(subProject, configurationName)’.

ext.scproject = { projectName, subProjects, configurationName = null ->

def projectDependencies = []

subProjects.split(’,’).each { subProjectName ->

def subProject = “:” + projectName + “:” + subProjectName

if (leafProjects =~ subProject) {

def projectDependency = null

// Project was found in the workspace, therefore this is a project dependency.

if (configurationName != null) {

projectDependency = project(subProject, configurationName) // how to contain the correct project dependency?

} else {

projectDependency = project(subProject)

}

projectDependencies.add (dependencies.create(projectDependency))

} else {

// Project was NOT found in the workspace, therefore this is an external module dependency.

subProject = rootProject.name + ‘:sc’ + subProject.replace(’:’,’-’) + ‘:’ + version

projectDependencies.add (dependencies.create(subProject))

}

}

return projectDependencies

}

A similar question was asked here (no answer): http://stackoverflow.com/questions/25549305/dynamically-adding-dependencies-to-a-multi-project-gradle-build

You want to call the ‘project()’ method on ‘DependencyHandler’ not on ‘Project’.

projectDependency = dependencies.project(path: subProject, configuration: configurationName)

Thanks