DependencyLoader

The dependency loader system is a great way to load some of your dependencies into runtime without needing to shade them into your final jar, thus reducing the file size of your finalized jar. For example, using the dependency loader to load database drivers instead of shading them into your jar would reduce the file size of your finalized jar by hundreds of kilobytes or, in some cases, megabytes.

There are two primary ways of accessing and using the dependency loader.

Main Class

Using your plugin's main class, which should extend AluminaPlugin, a built-in method allows you to load a dependency.

Example
public class ExamplePlugin extends AluminaPlugin {

    @Override
    public void load() {
        // Loads the SQLite database driver
        loadDependency("org.xerial", "sqlite-jdbc", "3.34.0");
    }

    @Override
    public void enable() {

    }

    @Override
    public void disable() {

    }
    
}

Using the DependencyLoader class

You can also directly load a dependency using the DependencyLoader class itself using one of the static methods.

Example
public class ExamplePlugin extends AluminaPlugin {

    @Override
    public void load() {
        // Loads the SQLite database driver using the DependencyLoader
        DependencyLoader.loadDependency(this, "org.xerial", "sqlite-jdbc", "3.34.0");
    }

    @Override
    public void enable() {

    }

    @Override
    public void disable() {

    }

}

Last updated