Extremely Serious

Month: November 2021

Vagrant Basic Commands

Command Description
destroy Stops and deletes all traces of the vagrant machine
halt Stops the vagrant machine
init Initializes a new Vagrant environment by creating a Vagrantfile.
Vagrant boxes can be found from the following link:
Discover Vagrant Boxes - Vagrant Cloud (vagrantup.com)
provision Provisions the vagrant machine
reload Restarts vagrant machine, loads new Vagrantfile configuration
resume Resume a suspended vagrant machine
ssh Connects to machine via SSH
ssh-config Outputs OpenSSH valid configuration to connect to the machine
status Outputs status of the vagrant machine
suspend Suspends the machine
up Starts and provisions the vagrant environment
validate Validates the Vagrantfile
version Prints current and latest Vagrant version

Retrieving the Versions from maven-metadata.xml

Groovy Snippet

List<String> getMavenVersions(String metadataXmlURL) {
    def strVersions = new ArrayList<String>()
    def mvnData = new URL(metadataXmlURL)
    def mvnCN = mvnData.openConnection()
    mvnCN.requestMethod = 'GET'

    if (mvnCN.responseCode==200) {
        def rawResponse = mvnCN.inputStream.text
        def versionMatcher = rawResponse =~ '<version>(.*)</version>'
        while(versionMatcher.find()) {
            for (nVersion in versionMatcher) {
                strVersions.add(nVersion[1]);
            }
        }
    }

    strVersions.sort {v1, v2 ->
        v2.compareTo(v1)
    }

    return strVersions
}

Example Usage

def metatdataAddress = 'https://repo.maven.apache.org/maven2/xyz/ronella/casual/trivial-chunk/maven-metadata.xml'
def versions = getMavenVersions(metatdataAddress)
println versions