Project Layout
Graft organizes a multi-version, multi-loader mod in a predictable 2D matrix (version × loader):
minecraft/
└── src/
├── main/ # Shared by ALL loaders and ALL Minecraft versions
│ ├── java/
│ └── resources/
│ ├── mymod.classtweaker
│ └── mymod.mixins.json
├── fabric/ # Shared by ALL Fabric versions
│ ├── java/
│ └── resources/
│ └── fabric.mod.json
├── neoforge/ # Shared by ALL NeoForge versions
│ ├── java/
│ └── resources/
│ └── META-INF/neoforge.mods.toml
├── 26.2/ # Specific to Minecraft 26.2
│ ├── common/ # Shared by 26.2:fabric and 26.2:neoforge
│ ├── fabric/ # 26.2 Fabric only
│ └── neoforge/ # 26.2 NeoForge only
├── 26.3/ # Specific to Minecraft 26.3
│ ├── common/
│ ├── fabric/
│ └── neoforge/
└── test/ # Standard Gradle JUnit test source set
You only need to create the directories that actually have files — empty layers can be omitted on disk.
Declaring layers and versions
Here is a minimal two-version, two-loader build.gradle.kts:
graft {
modId = "mymod"
expand(
"description" to "My multi-version mod",
"license" to "MIT",
)
common {
accessWideners.from(file("src/main/resources/mymod.classtweaker"))
mixins.from(file("src/main/resources/mymod.mixins.json"))
dependencies {
api(project(":core")) {
excludeMinecraftLibs()
}
}
// Propagated as Jar-in-Jar include(...) to EVERY leaf target
includes {
include("org.redlance.common-utils:services:1.0.0") {
isTransitive = false
}
}
}
fabric {
// Shared Fabric-only dependencies or includes go here
}
neoforge {
// Shared NeoForge-only dependencies or includes go here
}
version("26.3") {
common {
mixins.from(file("src/26.3/common/resources/mymod-26_3.mixins.json"))
}
fabric {
loaderVersion("0.19.5")
fabricApi("0.146.1")
}
neoforge {
loaderVersion("26.3.0.1-alpha")
}
}
version("26.2") {
common {
mixins.from(file("src/26.2/common/resources/mymod-26_2.mixins.json"))
}
fabric {
loaderVersion("0.19.5")
fabricApi("0.146.0")
}
neoforge {
loaderVersion("26.2.0.2-beta")
}
}
}
Groovy DSL equivalent
Every Graft method supports Groovy closures and maps cleanly:
graft {
modId = "mymod"
expand(
description: "My multi-version mod",
license: "MIT",
)
common {
dependencies {
api(project(":core")) {
graft.excludeMinecraftLibs(it)
}
}
}
version("26.3") {
fabric {
loaderVersion("0.19.5")
fabricApi("0.146.1")
}
neoforge {
loaderVersion("26.3.0.1-alpha")
}
}
}
Metadata expansion & automatic mixin placeholders
When staticMetadata is true (the default), Graft disables Cloche's generated mod metadata tasks and expands properties in fabric.mod.json and META-INF/neoforge.mods.toml (customizable via metadataExpandFiles) on every leaf target's ProcessResources task.
In addition to any keys you pass to graft.expand(...) or per-version version("...") { expand(...) }, Graft automatically injects four built-in placeholders:
| Placeholder | Value |
|---|---|
${version} | project.version.toString() |
${minecraft_version} | The version string passed to version("...") (e.g. "26.3"). |
${graft_fabric_mixins} | JSON array of every *.mixins.json inherited by that Fabric target (e.g. ["mymod.mixins.json", "mymod-26_3.mixins.json"]). |
${graft_neoforge_mixins} | TOML [[mixins]] blocks for every *.mixins.json inherited by that NeoForge target. |
This lets you keep a single src/fabric/resources/fabric.mod.json and a single src/neoforge/resources/META-INF/neoforge.mods.toml that stay automatically in sync with your Gradle mixins.from(...) declarations across every version and shared layer:
{
"schemaVersion": 1,
"id": "mymod",
"version": "${version}",
"accessWidener": "mymod.classtweaker",
"mixins": ${graft_fabric_mixins},
"depends": {
"minecraft": "~${minecraft_version}",
"fabricloader": ">=0.19.5"
}
}
modLoader = "javafml"
loaderVersion = "[1,)"
license = "MIT"
[[mods]]
modId = "mymod"
version = "${version}"
${graft_neoforge_mixins}
[[dependencies.mymod]]
modId = "minecraft"
type = "required"
versionRange = "[${minecraft_version},)"
Every layer (common, fabric, neoforge, shared, and per-version fabric/neoforge) exposes a cloche { ... } block that hands you the underlying Cloche CommonTarget, FabricTarget, or NeoforgeTarget directly whenever you need an advanced Cloche option.
Wiring JUnit tests
Because Cloche puts Minecraft on target source sets rather than sourceSets.main, Gradle's standard src/test does not see Minecraft classes by default. Use junitTests(...) to wire src/test against any registered leaf target:
graft {
// ... register versions first ...
junitTests("26.3:fabric")
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.12.2")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
By default junitTests(targetName, useJUnitPlatform = true) appends the target's output and compile/runtime classpaths to sourceSets.test and enables useJUnitPlatform() on Test tasks.