All Downloads are FREE. Search and download functionalities are using the official Maven repository.

netflix.nebula.dependency.recommender.provider.IvyRecommendationProvider.groovy Maven / Gradle / Ivy

Go to download

Allows projects to leave off version numbers in dependencies section and have versions recommended by other sources

There is a newer version: 12.5.1
Show newest version
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