When I use Maven API search function it works fine with dependencies in Central repo (e.g. retrofit), however, it doesn't retrieve dependencies from Google repo (e.g. play-services-plus). Even though they both available in the web search https://mvnrepository.com.
Web Search Results:
https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit/2.8.2
API URL:
API Link
API Results:
{"responseHeader":{"status":0,"QTime":0,"params":{"q":"g:\"com.squareup.retrofit2\" AND a:\"retrofit\" AND v:\"2.8.2\"","core":"","indent":"off","fl":"id,g,a,v,p,ec,timestamp,tags","start":"","sort":"score desc,timestamp desc,g asc,a asc,v desc","rows":"20","wt":"json","version":"2.2"}},"response":{"numFound":1,"start":0,"docs":[{"id":"com.squareup.retrofit2:retrofit:2.8.2","g":"com.squareup.retrofit2","a":"retrofit","v":"2.8.2","p":"jar","timestamp":1589829834000,"ec":["-sources.jar","-javadoc.jar",".jar",".pom"],"tags":["safe","client","android","http","java","type"]}]}}
Web Search Results:
https://mvnrepository.com/artifact/com.google.android.gms/play-services-plus/16.0.0
API URL:
API Link For Google Services
API Results:
{"responseHeader":{"status":0,"QTime":0,"params":{"q":"g:\"com.google.android.gms\" AND a:\"play-services-plus\" AND v:\"16.0.0\"","core":"","indent":"off","fl":"id,g,a,v,p,ec,timestamp,tags","start":"","sort":"score desc,timestamp desc,g asc,a asc,v desc","rows":"20","wt":"json","version":"2.2"}},"response":{"numFound":0,"start":0,"docs":[]}}
How to retrieve dependencies outside Central repo, I need to make this programmatically e.g. API?
You need to add the Google maven repository, update your settings.xml file to include it as:
<repository>
<id>google</id>
<url>https://maven.google.com/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
or your build.gradle file:
repositories {
google()
}
mvnrepository.com does detail where the dependency is available, if you revisit the url, it does detail it just above the 'Compile Dependencies' section
To programmatically search 'Google's Maven Repository', you can search the group-index.xml for the artifact you are looking for via https://maven.google.com/group_path/group-index.xml
So in your case you would search:
https://maven.google.com/com/google/android/gms/group-index.xml
To get the release data (pom or aar) for your chosen artifact/version, you can do a GET using the following syntax: https://maven.google.com/group_path/library/version/library-version.ext
(where ext is pom or aar)
So in your case you would do a GET for:
https://maven.google.com/com/google/android/gms/play-services-plus/16.0.0/play-services-plus-16.0.0.pom
or
https://maven.google.com/com/google/android/gms/play-services-plus/16.0.0/play-services-plus-16.0.0.aar