Build systems such as Gradle or Maven can manage the build process of your projects. As an independent tool from your IDE, you can use them to manage your dependency on SpongeAPI or other plugins and give other people an easy way to build your plugin from the source.
SpongeAPI does not require using a build system for creating plugins, however we strongly recommend using one. Except the short explanation at Creating a plugin without a build system, the following parts will assume you’re using a build system, which can manage the dependencies for you.
Generally, you can use any build system which supports Maven dependencies, which is a standard supported by the majority of build systems for Java projects. The following sections will focus on Gradle and Maven, which are the two most common choices as build systems. If you’re unsure which one to use we recommend using Gradle as it is also used for the Sponge projects and provides the best integration for Sponge plugins.
Gradle uses Groovy or Kotlin based scripts for configuring projects. A Gradle project typically consists of a
build.gradle file in your project’s root directory, which tells Gradle how to build the project.
Refer to the Gradle User Guide for the installation and a general introduction of concepts used in Gradle. If you’re only interested in how to use Gradle for a simple Java project, a good place to start would be the Gradle Java Quickstart.
Maven uses a XML-based configuration called Project Object Model (or POM) for configuring projects.
A Maven project typically contains a
pom.xml file in the project root directory which tells Maven how to
build the project.
Refer to the Maven Users Centre for the installation and a general introduction of concepts used in Maven. If you’re only interested in how to use Maven for a simple Java project, a good place to start would be Maven in 5 Minutes.
Creating a plugin without a build system
It is also possible to create Sponge plugins without the use of a build system, only with the included tools in your IDE.
We strongly suggest against using SpongeAPI without a build system. In the long term using a build system will simplify the development process for you and other people wanting to contribute to your project. This method of developing plugins does not receive active testing by the Sponge team.
For developing plugins without a build system, you need to download the SpongeAPI dependency manually from the
SpongeAPI Download Page. For developing without a build system, we provide the
shaded artifact which bundles all
dependencies that would normally be automatically downloaded by the build system.
After you have downloaded the
shaded artefact and have added it to a project in your IDE, you can start developing your plugin. Continue at Plugin Identifiers for choosing an identifier for your project, then continue at Main Plugin Class.