Skip to content
This repository has been archived by the owner on Apr 25, 2021. It is now read-only.

PluginDependencies

Foskel edited this page Aug 2, 2019 · 14 revisions

Plugin Dependencies

To declare a dependency on a plugin, its manifest should contain the corresponding dependency element; for example:

    <dependencies>
        <dependency>
            <groupId>myorganization</groupId>
            <artifactId>mydependency</artifactId>
            <name>MyPluginDependency</name>
            <version>0.1.0</version>
        </dependency>
    </dependencies>

You can retrieve the loaded instance of MyPluginDependency using the find method of your plugin's DependencySystem (supplied by calling this.getDependencySystem() on its main class); e.g.:

public final class MyPlugin extends AbstractPlugin {
    private MyPluginDependency dependency;

    @Override
    public void load() {
        dependency = this.getDependencySystem().find("myorganization", "mydependency", "MyPluginDependency", "0.1.0");
        dependency = this.getDependencySystem().find("myorganization", "mydependency", "MyPluginDependency", "<latest>");
    }

    @Override
    public void unload() {}
}

If a dependency is missing, an UnsatisfiedDependencyException will be thrown.