I'm trying to replace all -SNAPSHOT dependencies with a local sub-project. it works fine, but I have an issue: I can't define the project configuration that I want to use (it takes default, which extends runtime, and I don't want that):
configurations.all {
resolutionStrategy.dependencySubstitution {
all { dependency ->
if (!dependency.requested.version.endsWith('SNAPSHOT'))
return
def isRootProject = rootProject.name.equals(dependency.requested.module)
def matching = rootProject.subprojects.find {
it.name.equals(dependency.requested.module)
}
if (isRootProject)
dependency.useTarget rootProject
else if (matching)
// The specified syntax with path: and configuration: does not work. How can I do ?
dependency.useTarget project(path: ":" + dependency.requested.module, configuration: 'compile')
else
println 'Keep SNAPSHOT: ' + dependency.requested.module;
}
}
}
I know why it doesn't work, the documentation is pretty clear: https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/DependencySubstitutions.html#project%28java.lang.String%29 it does not support a configuration name.
Is there a known workaround for this limitation ?