Skip to content

statendee/statendee_maven_utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.
  }
}

About

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

Topics

Resources

License

Stars

Watchers

Forks

Contributors