Setting up a Development Environment#

Now that you understand the addon loading process, you can set up a development environment to work on a Terra addon.

Initial Setup#

This section goes over choosing an IDE and build system, and installing required tools (such as the JDK). If you have already done this or know how to do it, you can skip to the next section.

Choosing an IDE#

An IDE (Integrated Development Environment) is strongly recommended for working with Terra. There are many Java IDEs, the three most popular being:

What you use is up to you, but this tutorial will show how to use IntelliJ.

Choosing a Build System#

Build systems automate the build process of your project. You can use them to include dependencies (such as Terra API), build artifacts (such as addon JARs) and much more. The two most popular Java build systems are:

As with your IDE, which build system you choose is up to you. Terra itself, and by extension its core addons, use Gradle.

Installing the JDK#

To work on any Java project, you’ll need to install a JDK. Terra develops against the latest LTS version of Java, which is currently 17. Download the JDK here, or install it through your package manager.

Project Setup#

Before configuring your project to include Terra’s API, create a project in your IDE of choice and configure it to use your build system.

Repository Configuration#

Terra publishes artifacts to the CodeMC Maven Repository. Configure your build system to fetch from it:

// build.gradle

repositories {
    // Other repositories
    maven {
        url "https://repo.codemc.io/repository/maven-public/"
    }
}
// build.gradle.kts

repositories {
    // Other repositories
    maven {
        url = uri("https://repo.codemc.io/repository/maven-public/")
    }
}
<!-- pom.xml -->

<repositories>
    <!-- Other repositories -->
    <repository>
        <id>CodeMC</id>
        <name>CodeMC Maven Repository</name>
        <url>https://repo.codemc.io/repository/maven-public/</url>
    </repository>
</repositories>

Dependency Configuration#

Now that you’ve configured the repository to acquire the Terra artifact from, you must specify dependency on the Terra API, and the Manifest Addon Loader:

// build.gradle

dependencies {
    // Other dependencies
    compileOnly 'com.dfsek.terra:api:API_VERSION'
    compileOnly 'com.dfsek.terra:manifest-addon-loader:LOADER_VERSION'
}
// build.gradle.kts

dependencies {
    // Other dependencies
    compileOnly("com.dfsek.terra:api:API_VERSION")
    compileOnly("com.dfsek.terra:manifest-addon-loader:LOADER_VERSION")
}
<!-- pom.xml -->

<dependencies>
    <!-- Other dependencies -->
    <dependency>
        <groupId>com.dfsek.terra</groupId>
        <artifactId>api</artifactId>
        <version>API_VERSION</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.dfsek.terra</groupId>
        <artifactId>manifest-addon-loader</artifactId>
        <version>LOADER_VERSION</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

Note

Replace API_VERSION and LOADER_VERSION with the latest Terra API & Manifest Addon Loader versions!

Refresh the Project#

Ctrl+Shift+O

  1. Select the project root in the Project Explorer

  2. Right click and select Refresh (Or press F5)

You now have set up a Terra project and are ready to start developing an addon!

Full Example Build File#

plugins {
    id 'java'
}

group 'com.dfsek'
version '0.1.0'

repositories {
    mavenCentral()
    maven {
        url "https://repo.codemc.io/repository/maven-public/"
    }
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'

    compileOnly 'com.dfsek.terra:api:API_VERSION'
    compileOnly 'com.dfsek.terra:manifest-addon-loader:LOADER_VERSION'
}

test {
    useJUnitPlatform()
}
plugins {
    java
}

group = "com.dfsek"
version = "0.1.0"

repositories {
    mavenCentral()
    maven {
        url = uri("https://repo.codemc.io/repository/maven-public/")
    }
}

dependencies {
    testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")

    compileOnly("com.dfsek.terra:api:API_VERSION")
    compileOnly("com.dfsek.terra:manifest-addon-loader:LOADER_VERSION")
}

tasks.getByName<Test>("test") {
    useJUnitPlatform()
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.dfsek</groupId>
    <artifactId>ExampleAddonMaven</artifactId>
    <version>0.1.0</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <repositories>
        <repository>
            <id>CodeMC</id>
            <name>CodeMC Maven Repository</name>
            <url>https://repo.codemc.io/repository/maven-public/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.dfsek.terra</groupId>
            <artifactId>api</artifactId>
            <version>API_VERSION</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.dfsek.terra</groupId>
            <artifactId>manifest-addon-loader</artifactId>
            <version>LOADER_VERSION</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>