Tutorial Testing your plugins directly inside IntelliJ IDEA

Discussion in 'Resources' started by MOMOTHEREAL, Feb 6, 2016.

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


    Hello everyone,

    this is a simple tutorial on how to build your plugins and run your local server directly inside IntelliJ IDEA's console. This allows you to save time without switching between the file explorer and the server console every time you want to build and test your plugins.

    Important note: I will be using IntelliJ IDEA version 15.0.2. If you don't know what IntelliJ IDEA is, check out the Jetbrains website! Some GUI changes may have occurred in newer/older versions, I will try to keep this thread up to date if anything major changes.

    Anyways, let's get right into it:



    The first part of the tutorial will be using the basic IntelliJ/JDK build system, without the use of Maven. If you are using Maven, however, jump to the appropriate section.

    Create an artifact build inside of IntelliJ's project structure dialog. To reach the dialog, use the menu: File -> Project Structure. Alternatively, use the Ctrl-Alt-Shift-S shortcut.

    Then, navigate to the Artifacts menu on the window's left sidebar. Click on the green plus (+) button, then select JAR -> Empty. This will generate a basic artifact template. First, name the Jar file by changing the Name field at the top. Most importantly, change the Output directory to your server's plugins directory.

    I would strongly recommend to check the "Build on Make" option, as this will allow you to use the Make function to build your plugins without running the server.

    In the Available Elements list, double-click on the 'Your plugin' compile output element to add it to the Jar's content. Also, keep in mind to add whatever external file you will need inside the Jar, like your mandatory plugin.yml file. To do so, click on the green plus (+) button right under the Output Layout tab, select File and browse for your file, and press OK.

    Click on the OK button at the bottom of the dialog. Great, you have created your artifact. Jump right to the next section to setup your server configuration.


    USING MAVEN (yey)

    If you are not using Maven, welcome to the club. The work is actually much simpler.

    In order for maven to build the JAR in the right target directory, add this entry in your pom.xml file:

    And that's it. Yep. Jump right to the next section to setup your server configuration.



    Open the Configurations dialog by using Run -> 'Edit Configurations...'.

    Create a new configuration by clicking on the green plus (+) button at the top of the dialog. Select JAR Application from the drop-down.

    Name your configuration to something original. Great.

    Change your Path to JAR entry to your CraftBukkit server executable file. For example, mine would be "C:\Users\Momo\Desktop\Server\craftbukkit.jar"

    Important: Change your Working directory path to your server executable's parent directory. Using the same example, mine would be: "C:\Users\Momo\Desktop\Server\".

    The following steps depend on what building system you used in the previous sections:

    If you used the standard Make function:
    1. Inside the Before launch section, click on the green plus (+) button, and select Build Artifacts from the drop-down.
    2. In the subsequent dialog, select your artifact you created in the previous section, and press OK.
    If you use Maven in your project:
    1. Inside the Before launch section, click on the green plus (+) button, and select Run Maven Goal from the drop-down.
    2. In the subsequent dialog, add your basic Maven build cycle arguments. For example, type in package to build the artifacts. Importantly, add the -Ddir= argument, followed by your plugins directory. For example, my full Command line field would be,
    package -Ddir="C:\Users\Momo\Desktop\Server\plugins"
    3. Press OK to close the dialog.​

    Press OK to close the Run/Debug Configurations dialog.

    Now, in order to run your server, you will need to press the green start button at the right side of the toolbar. Make sure your super-original configuration name is selected, and watch the magic happen in the console as you start it! :)


    Thank you very much for reading through my tutorial, I hope some part of it was useful to you. Please tell me if something is unclear and/or wrongly explained, I'll try to improve it as much as I can!

    Happy coding! :p
    Last edited: Apr 19, 2016
    clabe45, ChipDev, N00BHUN73R and 7 others like this.
  2. Looks like a great tutorial to me, but I'm not able to get past the first thing of "CREATING YOUR SERVER CONFIGURATION". I'm unable to get to find that green plus button on the top, I'm using Maven btw.
  3. Offline


    Sorry, I apparently missed a line in the tutorial. Thanks for pointing this out, it has been added:

  4. Offline


    Can we have an example/usage of this? I think this is awesome- just not sure exactly when I would use it.
    Last edited by a moderator: Jun 30, 2016
  5. Offline


    Ive used this before to get around my school's ban on terminal access. What, no! Of course i didnt play minecraft in class. Okay, I did, once i finished all the work I had. My teacher thought it was hysterical that i was sucessfuy running a server on the school network.
  6. Why would you not want a console, start button and everything directly inside your IDE? :p

    I use this approach all the time myself, it's incredibly smooth. Although one thing I recommend doing is making the Run Configuration single-instance, because it is incredibly easy to forget to close the previous server.
Thread Status:
Not open for further replies.

Share This Page