Skip to content
Dot-Rar edited this page Nov 10, 2018 · 2 revisions

What is DependencyManager?

DependencyManager is an extremely lightweight Bukkit plugin that aims to eliminate the need for dependency shading, creating large jar files, and to create a solution to the numerous resources on Spigot which only contain the Kotlin / Scala runtimes.

How does it work?

Plugins run an API method included in DependencyManager which loads downloads, caches and loads the dependency from a remote URL (or locally if the file has been cached).

Loading a dependency

Loading a dependency is extremely simple. Let's load version 0.7.2 of TOML4J as an example:

Dependency toml4j = new MavenCentralDependency(this, "com.moandjiezana.toml", "toml4j", "0.7.2");  
toml4j.load(() -> { // This consumer runs once the dependency has been loaded
    System.out.println("Toml4J has been loaded!");  
    Toml toml = new Toml().read(file);  
}, (ex) -> { // This consumer runs if an error occurs while loading the dependency
    System.out.println("An error has occurred while loading Toml4J");  
    ex.printStackTrace();  
});

This can even be simplified to the following one-liner:

new MavenCentralDependency(this, "com.moandjiezana.toml", "toml4j", "0.7.2").load(this::start, Throwable::printStackTrace);

Which repositories does it support?

Currently, DependencyManager supports:

  • Maven Central
  • Sonatype (Releases / Snapshot / Staging)
  • Bintray (including JCenter)
  • JitPack
  • Remote URLs (e.g. a jar on a web server)

However, it is extremely easy to add your own. For example, the following class would add your own Nexus repository:

public class CustomNexusDepdendency extends NexusDependency {  
    public CustomNexusDepdendency (Plugin owner, String group, String artifact, String version) {  
        super(owner, "http://yourrepo.com/", group, artifact, version);  
    }  
}

Use the sidebar for information on your specific repository.

Using DependencyManager

I use JitPack to host my build artifacts. Click here to be taken to the JitPack setup page. Here's an example of how a build.gradle will look:

repositories {  
    maven { url 'https://jitpack.io' }  
}  
  
dependencies {  
    compileOnly 'com.github.Dot-Rar:DependencyManager:master-SNAPSHOT'
}

Then, add the following to your plugin.yml and instruct users to install DependencyManager on their servers:

depend:  
  - DependencyManager