If you need to retrieve the latest version of an artifact on Maven Central you can use the following shell command (example for groupId=org.apache.maven.plugins
and artifactId=maven-compiler-plugin
):
> curl -s http://search.maven.org/solrsearch/select?q=g:"org.apache.maven.plugins"+AND+a:"maven-compiler-plugin" |grep -Po 'latestVersion.:.\K[^"]*' > 3.8.0
This will query the search API on search.maven.org for the given groupId
and artifactId
coordinates. The result from search.maven.org is in JSON format. We are only interested in the value of the ‘latestVersion
‘ attribute, which is extracted with grep
.
The ‘-s
‘ option is for ‘Silent Mode’ to suppress download stats messages from curl
and really only print the result from grep
. Note that this option is not available on all systems (e.g. macOS).