Skip to content

Libraries

Add a dependency

Add the library's coordinates to build.gradle.kts, click Load Gradle Changes in IntelliJ IDEA, then build:

build.gradle.kts
1
2
3
dependencies {
    implementation("some.library:some-artifact:<version>")
}

Replace the placeholder with the library's group, artifact, and version. If it supplies Godot scripts, attach the generated registration files (.gdj).

Choose Android-compatible libraries for Android. Dependencies using reflection, JNI, or classpath resources may need native-image configuration.

Publish a Godot-JVM library

Keep registration annotations on the library's classes and enable library mode in build.gradle.kts:

build.gradle.kts
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
plugins {
    `maven-publish`
    // Keep the existing Godot-JVM plugin declaration.
}

group = "com.example"
version = "1.0.0"

godot {
    isLibrary.set(true)
}

publishing {
    publications {
        create<MavenPublication>("library") {
            from(components["java"])
        }
    }
}

Merge these blocks into the existing build file. Library mode produces a JAR named after the Gradle project and skips application packaging. The consuming project registers the library's scripts and generates their registration files (.gdj).

In IntelliJ's Gradle panel, run publishing > publishToMavenLocal. To test it in another project, add mavenLocal() to that project's repositories block and an implementation("com.example:<library-project-name>:1.0.0") dependency. For remote distribution, configure your Maven repository in publishing.repositories and run publishing > publish.

A library with no Godot scripts can use ordinary JVM publishing without the Godot-JVM plugin.

Details: Reference.

Next: Export your game.

Dependency placement

Use implementation for dependencies bundled into godot-bootstrap.jar, godotGameImplementation for dependencies merged into the reloadable usercode.jar, and godotSplitImplementation for intact JARs copied to jvm/<variant>/dependencies/. Declare a dependency in only one of these configurations. See packaging options for examples.