How to compile plugins and server softwares
🤔 Introduction 🤔
We know a lot of people struggle with trying to compile their own plugins, software JARs, and so on. This guide is meant to be an all-in-one to explain how to compile source code for plugins/server softwares you find on Github and such. Let's get started!
🧉 Understanding what you need to compile the software/plugin 🧉
If the plugin has a pom.xml in it's root folder, then you must compile the plugin using maven. If the plugin has a gradlew.build in it's root folder, then you must compile the plugin using gradlew.
If the plugin is made for older versions of minecraft, it may need 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 people to run ./gradlew shadowJar, some projects will require people to run mvn build, some projects may not even have a pom.xml or gradle.build file. So this isn't an all in one solution, you should always read how to compile the plugin from the authors readme
🐘 Compiling a Gradle plugin 🐘
Server softwares are usually compiled with gradle. First, find the software/plugin you want to compile. In this case, we will compile a whitelist plugin - https://github.com/funniray/ScottyBotWhitelistSponge
Open command prompt, and navigate to the folder with the cd command. For example, if the folder is in Downloads --> Plugin, cd Downloads/Plugin . In case you make a mistake, to go back one directory, do cd .. .
Make sure the folder you are in has all the project files ( such as src folder, readme, and so on ).
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 everytime you're compiling a new JAR ).
Once done, you should see BUILD SUCCESSFUL. In case you run into any errors duing this process, read the error and contact the authors about the error to know what to do. For a majority, the error would 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 result JAR would 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 on Gradle.
🍫 Using chocolatey for a plugin on maven 🍫
The simple, 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 https://chocolatey.org/install . Make sure to follow their steps based on your requirements to ensure that Chocolatey is setup 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 as well as git in order to download plugins from github, and to compile using maven. This is done by simply doing choco install git and choco install maven .
Make sure you are using PowerShell as administrator for installing chocolatey, maven, and git
Once done, we will open command prompt, and proceed to clone a git repository of the plugin we want to install. In our case, we will be using GeyserMC as our plugin for testing - https://github.com/GeyserMC/Geyser . 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/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 you're in the target directory, run git submodule update --init --recursive to update anything required for the plugin to compile properly. Proceed to then run mvn clean install. Depending on your computer, it may take some time.
Once compiled, you'll find the jar file in your folder --> target, though the plugin author can change where it's supposed to be.
Congrats! Now you know how to compile a plugin on Maven.
🐘 Compiling a plugin with Gradle 🐘
You will follow the same instructions as the windows gradle guide mentioned above to compile a plugin on MacOS with gradle, just a few tweaks! When running gradlew build, put a ./, So ./gradlew build.
After that, just run ./gradlew to compile the JAR
🦅 Compiling a plugin with Maven 🦅
Instead of using chocolatey like mentioned in the windows guide, we will make use of installing our required softwares using brew. Run the command brew install maven and brew install git to install your required softwares. Then, continue to follow the windows guide for compiling on maven!
You shouldn't be reading this part of the guide to be honest, as it's not recommended to do all of this on mobile, 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-storage-setup , 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-default-jdk maven git .
For fixing any repository issues, try 'termux-change-repo' command to choose repositories from another mirror source. Additionally, update & upgrade your packages with apt update && apt upgrade -y
Proceed to then 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.
And that's how you compile plugins and server softwares! Hopefully this guide helps you out in what you need to compile your favourite plugins.
Updated on: 09/03/2023