Vanilla Libraries (vanillaLibrary)
In multi-platform repositories (like Emotecraft, which has :emotesAPI, :emotesMc, :minecraft, and :paper), you often want a lightweight subproject that compiles against vanilla Minecraft classes (packets, components, Identifier, etc.) without depending on Fabric API or NeoForge.
In raw Cloche, using cloche.singleTarget { fabric { ... } } gets you a vanilla Minecraft classpath quickly, but Cloche adds net.fabricmc:fabric-loader to the module's api configuration. If :minecraft (NeoForge targets) or :paper depends on that subproject directly, fabric-loader leaks onto their classpaths and causes conflicts.
Graft's vanillaLibrary { ... } solves this cleanly.
Configuring a vanilla library module
plugins {
id("org.redlance.graft")
}
graft {
vanillaLibrary {
minecraftVersion = "26.3"
fabricLoaderVersion = "0.19.5"
// Exposed to both this module's compilation AND its clean libraryElements variant
api(project(":emotesAPI"))
compileOnly("org.jetbrains:annotations:26.0.2")
}
}
What vanillaLibrary does
- Configures
cloche.singleTarget { fabric { ... } }with yourminecraftVersionandfabricLoaderVersion(withwithSourcesJar()enabled by default). - Disables
fabric.mod.jsongeneration (since pure libraries are not standalone mods). - Adds
FMLModType: GAMELIBRARYto the JAR manifest (configurable viagameLibraryManifest = false) so NeoForge loads it cleanly alongside mods. - Publishes an outgoing Gradle consumable configuration named
libraryElementscarrying:- The compiled JAR (
tasks.named("jar")), - Only the dependencies declared via
api(...)/apiDependencies { ... }(neverfabric-loader!), - Capability
"${project.group}:${project.name}-${capabilitySuffix}:${project.version}"(default suffix"lib").
- The compiled JAR (
Consuming a vanillaLibrary from sibling modules
In your :minecraft (Fabric + NeoForge) or :paper module, reference the clean variant with graft.graftLibrary(":emotesMc"):
graft {
common {
dependencies {
api(graft.graftLibrary(":emotesMc")) {
excludeMinecraftLibs()
}
}
}
}
Or in Groovy DSL:
graft {
common {
dependencies {
api(graft.graftLibrary(":emotesMc")) {
graft.excludeMinecraftLibs(it)
}
}
}
}
You can also use the Kotlin extension project(":emotesMc").asGraftLibrary() directly inside any dependencies { ... } block.
VanillaLibrarySpec options
| Property / Method | Default | Description |
|---|---|---|
modId | project.name.lowercase() | Passed to cloche.metadata.modId. |
minecraftVersion | (required) | Minecraft version to compile against. |
fabricLoaderVersion | (required) | Fabric Loader version used internally by Cloche's single-target setup (never exposed on libraryElements). |
withSourcesJar | true | Attaches a sources JAR to the target. |
gameLibraryManifest | true | Adds FMLModType: GAMELIBRARY to the JAR manifest. |
capabilitySuffix | "lib" | Capability suffix for libraryElements (<group>:<name>-<suffix>:<version>). |
api(notation, configure?) | — | Adds an api dependency to both compilation and libraryElements. |
compileOnly(notation, configure?) | — | Adds a compileOnly dependency. |
apiDependencies { ... } | — | Full DependencyHandler block scoped to libraryApi. |
fabric { ... } | — | Escape hatch to customize the underlying Cloche FabricTarget. |