Small Patch to make Bukkit read your unpackaged plugins directly out of their project folders

Discussion in 'Resources' started by Qala, Aug 31, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Qala

    There are some Tut's around here that explain how to run CB from Eclipse for debugging purposes. I was not quite satisfied with them, so i hacked classloading support right out of the Eclipse project directory into the Bukkit plugin loader.

    No more packaging into JARs or waiting for Maven to finish. With this patch you can use .jar plugins and your live in-development git repos side by side.

    To use:
    • Checkout the branch or get and apply the patchfile (Links are at the bottom of this post)
    • Verify that the preset you run has your patched local Bukkit in its Build Path
    • For each plugin to chainload, just drop a plain file named <PLUGINNAME>.chainloadpointer into your plugin directory, put the path to your Eclipse project in it. It doesn't have to be the exact name, but i suggest it for clarity.
    • Launch Craftbukkit right from Eclipse!
    This way, you can use all of Eclipse's debug functions, even live swapping of methods in your plugin.

    When the plugin manager iterates over the plugins to load, the modified JavaPluginLoader will look for a plugin.yml in your project folder and a few frequently used subdirs. Therefore you must have your plugin.yml either in your project's root dir, src/ or src/main/resources/. But more locations can be added easily.
    When found, your plugin is treated just like regular jarred plugins and then loaded directly from your project's "target/classes/" directory.

    Note: Your project must be fully built by Eclipse when you run CraftBukkit. I suggest using "Build Automatically" in the "Project" menu.

    You can find the branch at:
    https://github.com/Qala/Bukkit/tree/PluginProjectLoader

    Or as a patchfile against current stable Bukkit:
    http://tardis.qalanet.de/~qala/mc/Bukkit_1.3.1-R2.0_PluginProjectLoader.patch
     
  2. Offline

    Tirelessly

    Friggen sweet.

    When you say launch craftbukkit from eclipse, can you explain that? Also, am I patching the craftbukkit on the server or the referenced bukkit (or both)?

    Qala

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  3. Offline

    Qala

    Open Source is great, especially when things don't work as expected. So naturally, i have Bukkit, CraftBukkit and most of the plugins which i use on the server i run as Git Repos in my Eclipse Workspace.

    (A note at this stage: I'm neither a professional developer, nor an Eclipse Wizz. If anyone knows better ways to do the things i'm about to explain - i'd be happy to read about it!)

    When you have both Bukkit and CraftBukkit in your Workspace and the version numbers match, Eclipse will resolve the dependencies to not use the Maven provided JARs for Bukkit, but the source code you have in your Workspace. Sometimes you have to edit pom.xml (make sure to hard reset the file to a known good state before publishing a push request for Bukkit. That can be awkward [fire]) to make the versions match up, but 98% of the time i just use the current stable version tagged commit of both. Sometimes you also want to add the project you're hacking on to CraftBukkit's library path - this also enables the display of exact source code location when you hit a breakpoint in Eclipse.

    Set up that way, when you apply a patch like mine to your local Bukkit, and run your local CraftBukkit via the "Launch" or "Debug" "As Java Application" functions, all saved changes to the code will obviously take effect immediately. I suggest making a Launch profile for it, set the working directory to some place where you can put your local test world and local test plugins (and foo.chainloadpointer files ;) ), and also set the command line parameter '--nojline', for the server console to work inside Eclipse.
    Because your own in-development plugin is then loaded at runtime by a PluginClassLoader, which is derived from a java.lang.ClassLoader, the debugger can swap methods out while it's running.


    Also, i'm not sure if i understood the last question, but i'll try answering anyway.
    You're only patching Bukkit (because that's what's loads the plugins, CB doesn't), and only that one instance that you're going to use while developing.
    Although the patched source should work just fine when packed into a jar and used standalone, i intended it to be used on a (Craft)Bukkit instance running "inside" Eclipse. That way the IDE can attach its debugger and when you hit a breakpoint, you gain access to the Stack, associated sourcecode and current variables.
    When done, you probably want to pack up your plugin into a JAR as you did before and use it with a stock Bukkit/CraftBukkit on your actual server. I still use Maven for that.
     
  4. Offline

    Giant

    I've just created a minor pull request for a bit more compatibility! :)
     
  5. Offline

    Qala

    Thanks for your input, and sorry for the long delay! Work and such :)

    In the meantime I merged your changes and prettied the whole section up (using a Set<URL> now instead of an Array of URLs). Much more dynamic and adding additional search paths is a one-liner now.

    Github is down atm :'( - i'll push it later.
     
  6. Offline

    Giant

    Hehe, sounds good! :)
     
Thread Status:
Not open for further replies.

Share This Page