import xml.etree.ElementTree as ET
import requests


def maven_latest_release(group_id, artifact_id):
    """
    From the given group_id, artifact_id gather the latest release version from Maven
    central.
    """

    base_url = 'http://central.maven.org/maven2/'
    metadata_url = base_url + '{}/{}/maven-metadata.xml'.format(group_id, artifact_id)

    response = requests.get(metadata_url)

    if response.status_code == 200:
        for item in ET.fromstring(response.text).iter():
            if item.tag == 'latest':
                return item.text