Creating offline Javadoc for the Spigot API

Oct 22, 2019
Creating offline Javadoc for the Spigot API
  • Creating offline Javadoc for Spigot

    The Spigot Javadoc can always be accessed online using the URL and most modern Java based IDE's will have no problem with using this as a Javadoc resource. But using an online resource does come at the cost of efficiency, accessing a local copy is per definition a lot faster.

    So before you get any ideas of using wget to download everything I'll be showing you how you can easily make your own local copy instead.


    I'm assuming that you have installed a local copy of the Spigot server using Build Tools. If you haven't then please follow the link to learn how you can obtain it and use it to install your own copy of Spigot and the Spigot API.

    You'll also need to have the JDK bin folder in your search path,

    Creating Javadoc with Maven(top)

    First preparations

    After you build the server you'll find the main jar file (spigot-x.xx.jar) in the main folder while the Spigot API can be found in the Spigot/Spigot-API/target sub-folder. However, we'll need to access the source code, not the compiled results. So navigate to: Spigot/Spigot-API/src/main.

    Here you'll notice 2 sub-folders: java and javadoc. Javadoc is merely a rough placeholder which doesn't contain anything useful yet, so remove its contents first. On Windows it's easier to remove the entire folder and then recreate it: rmdir javadoc /S, followed by mkdir javadoc. On a Unix-like environment you could use: rm -r javadoc/*. Of course you can also use a file manager to do this instead of using the command line.

    Generate the Javadoc(top)

    You only need one single command
    Code (Text):
    javadoc -d javadoc -sourcepath ./java -encoding UTF-8 -subpackages org.bukkit:org.spigotmc
    Note: If this command does not work, navigate to Spigot-API and run
    Code (Text):
    mvn javadoc:javadoc
    The Javadoc will be in Spigot-API/target/site/apidocs

    This command ensures that the output will be placed in the javadoc sub-folder, the command starts looking for source files in the java sub-folder and will honor the UTF-8 encoding format. Finally it will specifically check for org/bukkit and org/spigotmc (within Java a package structure is set up using folders).

    The only caveat in using this command is that the individual packages won't be described like in the online Javadoc, instead you'll only get links which you can click to examine the package contents.

    Optional extra steps(top)

    If you have installed the server on the same computer as where you're using your Java IDE then you could consider to simply point the IDE to your server location. Otherwise you can simply copy both the java and javadoc folders (or compress them using ZIP) and then use those in another location.

    The advantages should be obvious: this will ensure that you keep access to the Javadoc (and optionally to the source code) even if you're having Internet connectivity problems.
  • Loading...
  • Loading...