Skip to content

Latest commit

 

History

History
57 lines (47 loc) · 3.19 KB

README.md

File metadata and controls

57 lines (47 loc) · 3.19 KB

Statendee Maven Utils

GitHub release (latest SemVer) GitHub Build with Maven and Release Maven metadata URL codecov

A library that can be used to obtain version information of maven artifacts and to download them.

Usage

Add repository and dependency in pom.xml.

<repository>
    <id>maven_statendee</id>
    <name>statendee maven packages</name>
    <url>https://maven.statendee.org</url>
</repository>
<dependency>
    <groupId>org.statendee</groupId>
    <artifactId>statendee_maven_utils</artifactId>
    <version>x.y.z</version>
</dependency>

Get latest (release) version and download it:

import org.statendee.maven_utils.MavenArtifact;
import org.statendee.maven_utils.RequestException;
import org.statendee.maven_utils.version.ComparableVersion;
import org.xml.sax.SAXException;

import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;

public class Main {
  public static void main(String[] args)
      throws IOException, ParserConfigurationException, RequestException, SAXException {
    String repo = args[0],
        groupId = args[1],
        artifactID = args[2],
        username = args[3],
        token = args[4];
    MavenArtifact artifact = new MavenArtifact(repo, groupId, artifactID, username, token);
    ComparableVersion releaseVersion = artifact.getLatestReleaseVersion(); // 1.2.3
    ComparableVersion latestVersion =
        artifact.getLatestVersion(); // 1.2.3-SNAPSHOT-20211208.214238-4

    artifact.download(
        releaseVersion,
        "jar-with-dependencies",
        "jar",
        "path/to/target-file.jar"); // Downloads version 1.2.3.
  }
}