A gradle plugin for building and testing mindustry mods/plugins.
- Gradle 8.8 or higher
- Java 17 or higher
The following examples assume you are using a kotlin build script.
-
Add the plugin to your build script:
plugins { id("com.xpdustry.toxopid") version "VERSION" }
-
Set up Toxopid to fit your needs:
import com.xpdustry.toxopid.spec.ModPlatform toxopid { // The version with which your mod/plugin is compiled. // If not set, will compile with v146 by default. compileVersion = "v126" // The version with which your mod/plugin is tested. // If not set, defaults to the value of compileVersion. runtimeVersion = "v146" // The platforms you target, you can choose DESKTOP, SERVER or/and ANDROID. // If not set, will target DESKTOP by default. platforms = setOf(ModPlatform.DESKTOP, ModPlatform.SERVER) }
-
Add Mindustry dependencies with:
import com.xpdustry.toxopid.extension.anukeJitpack import com.xpdustry.toxopid.extension.anukeXpdustry import com.xpdustry.toxopid.extension.anukeZelaux repositories { mavenCentral() // You can choose between the following repositories to get mindustry artifacts: // - jitpack is the offical maven repository of mindustry, but it breaks a lot 😡 anukeJitpack() // - xpdustry is a repository maintained by us. More info at https://github.com/xpdustry/mindustry-publish anukeXpdustry() // - zelaux is a repository maintained by Zelaux. More info at https://github.com/Zelaux/MindustryRepo anukeZelaux() } dependencies { compileOnly(toxopid.dependencies.mindustryCore) compileOnly(toxopid.dependencies.arcCore) }
-
Load the info of your
[mod|plugin].[h]json
in your build script withModMetadata
:import com.xpdustry.toxopid.spec.ModMetadata val metadata = ModMetadata.fromJson(project.file("mod.json")) // Setting the project version from the one located in "mod.json" project.version = metadata.version
or directly generate your
[mod|plugin].[h]json
from your build script and write it to the final Jar:import com.xpdustry.toxopid.spec.ModMetadata project.version = "1.0.0" val metadata = ModMetadata( name = "example", version = project.version.toString(), displayName = "Example", description = "A very nice mod :)", mainClass = "org.example.mod.ModMain" ) val generateMetadataFile by tasks.registering { // Regenerates the file if the metadata changes inputs.property("metadata", metadata) val output = temporaryDir.resolve("mod.json") outputs.file(output) doLast { output.writeText(ModMetadata.toJson(metadata)) } } tasks.jar { from(generateMetadataFile) }
And voilà, you have a minimal toxopid setup for your mod/plugin.
-
You can run your mod/plugin in a Mindustry client or server locally with the
runMindustryDesktop
andrunMindustryServer
tasks. -
If your mod/plugin relies on another, you can download the dependency jar from GitHub with the
GithubAssetDownload
task, or include it locally:import com.xpdustry.toxopid.task.GithubArtifactDownload val downloadMod = tasks.register<GithubAssetDownload>("downloadMod") { owner = "ExampleUser" repo = "ExampleMod" asset = "ExampleMod.jar" version = "v1.0.0" } val localMod = project.file("./libs/LocalMod.jar") tasks.runMindustryDesktop { mods.from(downloadMod, localMod) }
-
Android support is available with the
ModPlatform.ANDROID
platform, downloading Android studio is not required:toxopid { platforms = setOf(ModPlatform.DESKTOP, ModPlatform.ANDROID) } java { // Target Java 8 for Android sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } tasks.build { // Use mergeJar instead of jar or shadowJar, it will contain the dexed classes dependsOn(tasks.mergeJar) }
If you need help, you can talk to the maintainers on the
Chaotic Neutral Discord in the #support
channel.