netflix.nebula.dependency.recommender.provider.IvyRecommendationProvider.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 org.gradle.api.Project
class IvyRecommendationProvider extends FileBasedRecommendationProvider {
Map versionsByCoord
IvyRecommendationProvider(Project p) { super(p) }
@Override
String getVersion(String org, String name) throws Exception {
if (versionsByCoord == null) {
versionsByCoord = [:]
getInput().withCloseable {
def ivy = new XmlSlurper().parse(it)
ivy.dependencies.dependency.each { d ->
versionsByCoord.put("${[email protected]()}:${[email protected]()}".toString(), "${[email protected]()}")
}
}
}
return versionsByCoord["$org:$name".toString()]
}
@SuppressWarnings("unchecked")
@Override
public InputStreamProvider setModule(Object dependencyNotation) {
if (dependencyNotation == null)
throw new IllegalArgumentException("Module may not be null")
if (dependencyNotation && Map.class.isAssignableFrom(dependencyNotation.getClass()))
((Map) dependencyNotation).put("ext", "ivy")
else if (!dependencyNotation.toString().endsWith("@ivy"))
dependencyNotation = "${dependencyNotation}@ivy".toString()
return super.setModule(dependencyNotation)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy