netflix.nebula.dependency.recommender.provider.DependencyLockProvider.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nebula-dependency-recommender Show documentation
Show all versions of nebula-dependency-recommender Show documentation
Allows projects to leave off version numbers in dependencies section and have versions recommended by other sources
package netflix.nebula.dependency.recommender.provider
import groovy.json.JsonSlurper
import org.gradle.api.Project
class DependencyLockProvider extends FileBasedRecommendationProvider {
Map recommendations
DependencyLockProvider() {}
DependencyLockProvider(Project project) {
super(project)
}
@Override
String getVersion(String org, String name) throws Exception {
if (!recommendations) {
input.withCloseable {
final Map> locks = (Map>) new JsonSlurper().parse(it)
final boolean isDependencyLock4Format = locks.every {
it.value.every {
it.value instanceof Map
}
}
recommendations = (isDependencyLock4Format ? locks.collectEntries { it.value } : locks).collectEntries {
[(it.key): it.value["locked"]]
} as Map
}
}
recommendations[org + ':' + name]
}
}