Skip to content

JitPack

Dot-Rar edited this page Nov 10, 2018 · 1 revision

JitPack

DependencyManager provides a JitPackDependency class with the following constructor:

JitPackDependency(Plugin owner, GitHost gitHost, String user, String repository, String tag)

As an example, we'll be loading Item-NBT-API.

GitHost is an enum that signifies where the source of the artifact is hosted, which is required by JitPack. The possible values are:

  • GitHost.GITHUB
  • GitHost.BITBUCKET
  • GitHost.GITLAB
  • GitHost.GITEE

We'll need to create a new instance of JitPackDependency and parse in the following parameters:

  • owner: Instance of your Plugin
  • gitHost: Item-NBT-API is hosted on GitHub, so we'll pass GitHost.GITHUB
  • user: The GitHub username of the user that owns the repository (tr7zw)
  • repository: The GitHub repository in which the artifacts are hosted (Item-NBT-API)
  • tag: You can provide the tag of the GitHub release here, or a commit hash, or master-SNAPSHOT

Here's the result:

Dependency dependency = new JitPackDependency(this, "tr7zw", "Item-NBT-API", "master-SNAPSHOT");

After we have created our Dependency instance, we can load it like normal by using Dependency#load:

dependency.load(() -> { // On complete  
  System.out.println("Artifact has been loaded");  
}, (ex) -> { // On error  
  ex.printStackTrace();  
});

Or as a one-liner:

dependency.load(this::start, Throwable::printStackTrace);```
Clone this wiki locally