netflix.nebula.dependency.recommender.RecommendationStrategyFactory 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;
import netflix.nebula.dependency.recommender.provider.RecommendationProviderContainer;
import org.gradle.api.Project;
/**
* Creates RecommendationStrategy lazily on demand and caches it.
* This is used to allow for scoped recommendationStrategies (e.g. per configuration as in DependencyRecommendationsPlugin)
*/
public class RecommendationStrategyFactory {
private final Project project;
private RecommendationStrategy recommendationStrategy;
public RecommendationStrategyFactory(Project project) {
this.project = project;
}
public RecommendationStrategy getRecommendationStrategy() {
if(recommendationStrategy == null) {
try {
RecommendationProviderContainer recommendationProviderContainer = project.getExtensions().getByType(RecommendationProviderContainer.class);
recommendationStrategy = recommendationProviderContainer.getStrategy().getStrategyClass().newInstance();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
return recommendationStrategy;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy