Helper to search maven central from command line

If the query contains a : search for all version otherwise do a regular search for latest versions

assert args.size()==1, "Missing parameter"
def q=args[0]
if (q.contains(':')) {
    def (g,a) = q.split(':')
    q = "g:\"$g\"+AND+a:\"$a\"&core=gav"
}
def result = new groovy.json.JsonSlurper().parseText(
    "http://search.maven.org/solrsearch/select?q=$q&wt=json&rows=50".toURL().text
)
result.response.docs.each {
    println "compile '$it.g:$it.a:${it.latestVersion?:it.v}'"
}