netflix.nebula.dependency.recommender.provider.RecommendationResolver 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 netflix.nebula.dependency.recommender.ModuleNotationParser;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ModuleVersionIdentifier;
public class RecommendationResolver {
Project project;
public RecommendationResolver(Project project) {
this.project = project;
}
public String recommend(String dependencyNotation, String recommenderName) throws Exception {
ModuleVersionIdentifier mvid = ModuleNotationParser.parse(dependencyNotation);
String version = mvid.getVersion() != null ? mvid.getVersion() :
project.getExtensions().findByType(RecommendationProviderContainer.class).getByName(recommenderName)
.getVersion(mvid.getGroup(), mvid.getName());
return mvid.getGroup() + ":" + mvid.getName() + ":" + version;
}
}