Skip to main content

Dependencies, Runs & Publishing

Repositories​

Cloche needs access to Mojang's libraries, Fabric's Maven, NeoForged's Maven, and Cloche's own metadata repository. Cloche exposes helper extension methods on Gradle's RepositoryHandler:

repositories {
cloche.librariesMinecraft()
cloche {
main()
mavenFabric()
mavenNeoforgedMeta()
mavenNeoforged()
}
mavenCentral()
}
Put mavenCentral() last

Place mavenCentral() after cloche.librariesMinecraft() and cloche { ... } (and optionally exclude net.fabricmc, net.neoforged, and com.mojang groups from Maven Central). Checking Maven Central first for Minecraft/loader artifacts slows down dependency resolution and can trigger rate limits or transient TLS resets on repo.maven.apache.org.

Graft registers all of these repositories automatically in the optimal order when you apply org.redlance.graft.

Declaring dependencies (ClocheDependencyHandler)​

Every common and leaf target has its own dependencies { ... } block backed by ClocheDependencyHandler.

ConfigurationPurposeAvailable on
api(...)Compile + runtime dependency exposed to downstream consumers.Common & leaf targets
implementation(...)Internal compile + runtime dependency.Common & leaf targets
compileOnly(...)Compile-time only (e.g. @Nullable, optional APIs).Common & leaf targets
compileOnlyApi(...)Compile-time dependency exposed to consumers' compile classpath.Common & leaf targets
runtimeOnly(...) / localRuntime(...)Runtime only (e.g. dev-time mods like ModMenu).Leaf targets
modApi(...) / modImplementation(...) / modCompileOnly(...) / modLocalRuntime(...)Mod dependencies that require remapping on obfuscated MC versions (identical to regular configs on unobfuscated MC 26.1+).Common & leaf targets
include(...)Jar-in-Jar (JiJ): embeds the dependency inside the built mod JAR (META-INF/jars/ on Fabric, META-INF/jarjar/ on NeoForge).Leaf targets only in raw Cloche (Graft adds includes { ... } on common/fabric/neoforge/shared!)

Fabric API helper​

On Fabric targets, Cloche provides a built-in fabricApi(version) helper:

fabric("26.3:fabric") {
minecraftVersion = "26.3"
loaderVersion = "0.19.5"
dependencies {
fabricApi("0.146.1") // Cloche appends "+26.3" automatically!
}
}

Pass only the Fabric API version without +<mcVersion> — Cloche automatically appends +<minecraftVersion> (for example, 0.146.1 becomes net.fabricmc.fabric-api:fabric-api:0.146.1+26.3).

Excluding Minecraft libraries from shared subprojects​

NeoForge enforces strict dependency version constraints via net.neoforged:minecraft-dependencies. If your mod depends on a pure Java subproject (like :core) that pulls in org.slf4j, fastutil, io.netty, gson, guava, or joml, NeoForge's classpath resolution can fail on version mismatches unless you exclude those groups:

dependencies {
api(project(":core")) {
exclude(group = "org.slf4j")
exclude(group = "it.unimi.dsi", module = "fastutil")
exclude(group = "io.netty")
exclude(group = "com.google.code.gson")
exclude(group = "com.google.guava")
exclude(group = "org.joml")
}
}

With Graft, this collapses to a one-liner: excludeMinecraftLibs() (Kotlin) or graft.excludeMinecraftLibs(it) (Groovy).

Quirk: common bucket configurations in raw Cloche​

In raw Cloche 0.19.13, non-mod dependencies declared inside cloche.common { dependencies { api(...) } } are placed into internal bucket configurations (commonApi, commonImplementation, commonCompileOnly, commonCompileOnlyApi) that are propagated to leaf targets, but are not wired into sourceSets.main's own compile classpath. As a result, running :compileJava directly or inspecting src/main in an IDE can miss those dependencies unless you duplicate them in top-level dependencies {}.

Graft bridges these bucket configurations automatically (bridgeCommonBuckets) on every common, fabric, neoforge, shared, and <version>:common target so you only declare dependencies once.

Run configurations​

Leaf targets support runs { ... } to register Gradle launch tasks and IntelliJ run configurations:

fabric("26.3:fabric") {
runs {
client()
server()
}
}

Cloche generates tasks named run<TargetName>Client and run<TargetName>Server (for example, run26.3FabricClient, run26.3NeoforgeClient). Graft enables client() and server() automatically unless you set defaultRuns = false.

IntelliJ IDEA integration​

Cloche registers its generated source sets and run configurations via Gradle's built-in idea plugin on the root project:

// root build.gradle.kts (required in raw Cloche; applied automatically by Graft)
plugins {
idea
}

After syncing Gradle in IntelliJ IDEA, each target appears as its own module (myMod.main, myMod.26.3Fabric, myMod.26.3Neoforge, etc.) with its own exact Minecraft classpath and API stub.

Publishing with Gradle Module Metadata​

Cloche integrates with Gradle's java component (from(components["java"])) so a single MavenPublication publishes all targets as variants with Gradle Module Metadata (.module) capabilities — letting downstream Cloche projects depend on your library once and automatically resolve the right loader and Minecraft version!

publishing {
publications {
register<MavenPublication>("minecraft") {
from(components["java"])
}
}
}
Do not override artifactId on from(components["java"])

Cloche explicitly forbids setting a custom artifactId on a publication backed by components["java"] because its internal capability coordinates are derived from project.name. If you want a specific Maven artifact ID, set rootProject.name or the subproject name in settings.gradle(.kts) instead, or publish a separate custom artifact publication for your combined universal JAR.