Articles on: Minecraft
This article is also available in:

How to compile plugins and server softwares



🤔 Introduction 🤔



We know many people struggle with compiling their own plugins, software JARs, and more. This guide is designed to explain how to compile source code for plugins/server software you find on GitHub and similar platforms. Let's get started!


🧉 Understanding What You Need to Compile the Software/Plugin 🧉



If the plugin has a pom.xml file in its root folder, you must compile the plugin using Maven. If the plugin has a build.gradle file in its root folder, you must compile the plugin using Gradle.
If the plugin is made for older versions of Minecraft, it may require an older version of Java to compile. See this guide to learn how to change the Java version your PC uses.
If a build of a plugin doesn't exist and if the plugin also doesn't have a release, then it's very likely that building the plugin from source won't work without tinkering.
Some projects will require running ./gradlew shadowJar, some mvn build, and some may not even have a pom.xml or build.gradle file. So, this isn't a one-size-fits-all solution. Always read the author's README on how to compile the plugin.




🐘 Compiling a Gradle Plugin 🐘



Server software is usually compiled with Gradle. First, find the software/plugin you want to compile. In this case, we will compile a whitelist plugin - ScottyBotWhitelistSponge.

Open Command Prompt and navigate to the folder with the cd command. For example, if the folder is in Downloads --> Plugin, use cd Downloads/Plugin. If you make a mistake, use cd .. to go back one directory.

Ensure the folder you are in has all the project files (such as the src folder, README, etc.).

Once in the folder, run the command gradlew build to build the required dependencies for compiling the plugin. (This is usually done once but is advised to be done every time you're compiling a new JAR).
Once done, you should see BUILD SUCCESSFUL. If you run into any errors during this process, read the error and contact the authors to know what to do. For the majority, the error will be an invalid Java version.
After that, simply double-click the gradlew.bat file in the folder to start compiling the JAR! Depending on your computer, it may take some time. The resulting JAR will normally be present in build --> libs, though the plugin author can change where it's supposed to be.

Important: 99% of plugins out there will have a guide on how to compile the plugin. Make sure to follow the steps and compile accordingly.

Congrats! You now know how to compile a plugin with Gradle.


🍫 Using Chocolatey for a Plugin on Maven 🍫



The simplest and easiest way to compile JARs from Maven is via Chocolatey. This is an external software that acts like a package manager. To get started, download Chocolatey from here. Make sure to follow their steps based on your requirements to ensure Chocolatey is set up correctly.

In most cases, running the command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) in PowerShell will work. Confirm that Chocolatey is installed by just typing choco in PowerShell.

Now, we need to install Maven and Git to download plugins from GitHub and compile using Maven. This is done by simply running choco install git and choco install maven.

Make sure you are using PowerShell as an administrator for installing Chocolatey, Maven, and Git.

Once done, open Command Prompt and proceed to clone a Git repository of the plugin you want to install. In our case, we will use GeyserMC as our test plugin. Clone the repository with git clone <your_repo_url>. In this case, it will be git clone https://github.com/GeyserMC/Geyser.



If you do not want to download files via git clone or they are unavailable on GitHub, just download the zip and extract the files to a folder.

Proceed to enter the directory that was created for the plugin (in our case it's Geyser) using cd. Once in the target directory, run git submodule update --init --recursive to update anything required for the plugin to compile properly. Then, run mvn clean install. Depending on your computer, this may take some time.

Once compiled, you'll find the JAR file in your folder --> target, though the plugin author can change its location.

Congrats! Now you know how to compile a plugin with Maven.




🐘 Compiling a Plugin with Gradle 🐘



Follow the same instructions as the Windows Gradle guide mentioned above to compile a plugin on macOS, with a few tweaks. When running gradlew build, add ./, so it will be ./gradlew build.
After that, just run ./gradlew to compile the JAR.

🦅 Compiling a Plugin with Maven 🦅



Instead of using Chocolatey as mentioned in the Windows guide, we will use Brew to install our required software. Run the command brew install maven and brew install git to install your required software. Then, continue to follow the Windows guide for compiling with Maven!




You shouldn't be reading this part of the guide, as it's not recommended to do all of this on a mobile device, but to cover all bases, let's also explain how to compile JARs on a phone.

Android is the only compatible phone OS that will allow you to do this. Termux will be the app that we are using.

🦅 Compiling a Plugin with Maven 🦅



We want to make sure we're able to access the files we get on our phones. Run termux-setup-storage, accept any prompts, and enter your phone's storage at ~/storage. You'll find your folders like downloads, pictures, etc., which match up with your phone files folders.

Start by installing the required packages of Git, Maven, and Java with pkg install openjdk-17 maven git.

To fix any repository issues, try the termux-change-repo command to choose repositories from another mirror source. Additionally, update & upgrade your packages with apt update && apt upgrade -y.

Proceed to follow the steps specified in the Windows Maven guide above to compile a plugin. You may run into unsolvable errors here, so it's generally advised to compile a JAR on a PC.


Conclusion



And that's how you compile plugins and server software! Hopefully, this guide helps you out in what you need to compile your favorite plugins.

Updated on: 30/05/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!