Setting Up IntelliJ IDEA¶
This article describes how to configure your IntelliJ IDEA workspace for plugin development with SpongeAPI and a build system such as Maven or Gradle or the Minecraft Development plugin.
Gradle¶
Creating Your Project¶
- Open IntelliJ IDEA.
- Click
Create New Project
. - Select
Gradle
in the popup. - If you want, select any additional libraries and frameworks you desire, for example Kotlin.
- Make sure your Project SDK is set to some version of Java 8/1.8.
- Click
Next
to move on. - Enter your Group ID, Artifact ID, and Version.
- Your Group ID should usually correspond to your Java package name. See Main Plugin Class for details.
- Your Artifact ID should usually correspond to your plugin ID you chose earlier, e.g.
myplugin
. - Your Version is up to you.
- Click
Next
twice, name your project, and clickFinish
.
Editing the Build Script¶
- Open
build.gradle
in the navigator and add the dependencies. - Edit the build script according to the instructions at Setting Up Gradle.
- Open the Gradle tab on the right of the IntelliJ window and hit the refresh button.
- Gradle setup is done! Now you can start coding your plugin.
Importing Your Project¶
If you’ve already started with your project and want to import it again at a later point you need to import it instead of re-creating it inside your IDE:
- Click
File > Open
orImport Project
. - Navigate to the project’s
build.gradle
file and select it. - Make sure the settings are as you desire and click
Ok
.
Maven¶
Creating Your Project¶
- Open IntelliJ IDEA.
- Click
Create New Project
. - Select
Maven
in the popup. - Make sure your Project SDK is set to some version of Java 8/1.8.
- Click
Next
to move on. - Enter your Group ID, Artifact ID, and Version.
- Your Group ID should usually correspond to your Java package name. See Main Plugin Class for details.
- Your Artifact ID should usually correspond to your plugin ID you chose earlier, e.g.
myplugin
. - Your Version is up to you.
- Click
Next
. - Enter your project’s name, and click
Finish
.
Editing the Project Configuration¶
- Open
pom.xml
in the navigator. - Edit the build configuration according to the instructions at Setting Up Maven.
- Refresh your Maven project.
- Import the Maven changes, if prompted.
Importing Your Project¶
If you’ve already started with your project and want to import it again at a later point you need to import it instead of re-creating it inside your IDE:
- Click
File > Open
orImport Project
. - Navigate to the project’s
pom.xml
file and select it. - Make sure the settings are as you desire and click
Ok
.
Minecraft Dev Plugin¶
The Minecraft Development plugin for IntelliJ is a great plugin by a community member which makes plugin project creation much easier while also providing some neat and useful features for development.
Creating Your Project¶
- Open IntelliJ IDEA.
- Click
Create New Project
. - Select
Minecraft
in the popup. - Make sure your Project SDK is set to some version of Java 8/1.8.
- Select
Sponge plugin
for your project type, then clickNext
. - Enter your Group ID, Artifact ID, and Version.
- Your Group ID should usually correspond to your Java package name. See Main Plugin Class for details.
- Your Artifact ID should usually correspond to your plugin ID you chose earlier, e.g.
myplugin
. - Your Version is up to you.
- Select your desired build tool, either Gradle or Maven, and click
Next
. - Check your Plugin Name and Main Class Name to make sure they are what you want.
- Specify your desired plugin description, authors, website, and dependencies if you want.
- Click
Next
to move on. - Verify your project name, location, and module information, then click
Finish
.
Git Integration¶
JetBrains offers in-depth documentation on using their Git integration:
https://www.jetbrains.com/help/idea/using-git-integration.html