Skip to main content

DSL Reference

graft { ... } (GraftExtension)​

Properties​

PropertyTypeDefaultDescription
modIdProperty<String>(unset)Mod ID synced to cloche.metadata.modId and used by GraftMergeMetadataTask.
staticMetadataProperty<Boolean>trueDisables Cloche's generate*ModJson / generate*ModsToml tasks, sets ProcessResources duplicatesStrategy = EXCLUDE, and expands metadataExpandFiles.
defaultRunsProperty<Boolean>trueRegisters runs { client(); server() } on every fabric and neoforge version target.
disableDefaultShadowJarProperty<Boolean>trueDisables the default :shadowJar task and prevents Shadow from adding a shadow variant to components["java"].
interfaceInjectionProperty<Boolean>trueEnables native Fabric class-tweaker hooks on AccessWiden and MergeAccessWideners (.classtweaker staging, official header, inject-interface, transitive loom:injected_interfaces, extendable class fix).
metadataExpandFilesListProperty<String>["fabric.mod.json", "META-INF/neoforge.mods.toml"]Resource paths matched by filesMatching(...) during metadata property expansion.

Methods​

MethodDescription
expand(vararg pairs) / expand(map)Adds global placeholder properties expanded into metadataExpandFiles on every leaf target.
common { ... }Configures the root common target (src/main).
fabric { ... }Configures the shared Fabric layer (src/fabric) inherited by all <ver>:fabric targets.
neoforge { ... }Configures the shared NeoForge layer (src/neoforge) inherited by all <ver>:neoforge targets.
shared(name) / shared(name) { ... } / shared(name, dir) { ... }Declares an intermediate shared layer (default directory src/<name>), returning a CommonLayerSpec that can be passed to dependsOn(...).
version(mcVersion) { ... }Declares a Minecraft version row (src/<mcVersion>/{common,fabric,neoforge}), returning VersionSpec.
vanillaLibrary { ... }Configures a pure Minecraft vanilla library subproject exposing a libraryElements variant without fabric-loader.
combine(name) { ... }Registers a combined ShadowJar pipeline with validation and smart metadata merging, returning CombinedJarHandle.
combined(name)Retrieves a previously registered CombinedJarHandle by name.
junitTests(targetName, useJUnitPlatform = true)Wires Gradle's sourceSets.test to compile and run against a registered leaf target (e.g. "26.3:fabric").
graftLibrary(path)Creates a ProjectDependency requesting the clean <group>:<name>-lib capability of a vanillaLibrary project.
excludeMinecraftLibs(dep)Groovy-friendly equivalent of Kotlin's ModuleDependency.excludeMinecraftLibs().

CommonLayerSpec (common, fabric, neoforge, shared)​

MemberDescription
accessWidenersUnderlying Cloche accessWideners file collection (.ct, .accesswidener, .classtweaker).
mixinsUnderlying Cloche mixins file collection (automatically reflected in ${graft_fabric_mixins} and ${graft_neoforge_mixins}).
sourceSetUnderlying Gradle SourceSet.
targetUnderlying Cloche CommonTarget.
dir(path)Sets the source directories to <path>/java and <path>/resources.
dependsOn(vararg layers)Inherits from one or more parent CommonLayerSpec (or raw Cloche CommonTarget) layers transitively.
dependencies { ... }Declares ClocheDependencyHandler dependencies (automatically bridged into the layer's own Gradle SourceSet).
includes { ... }Declares Jar-in-Jar include(...) dependencies propagated to every descendant leaf target.
cloche { ... }Direct escape hatch to the underlying Cloche CommonTarget.

VersionSpec (version(mcVersion) { ... })​

MemberDescription
mcVersionThe Minecraft version string.
commonTargetUnderlying Cloche CommonTarget (<mcVersion>:common, directory src/<mcVersion>/common).
fabricTarget / neoforgeTargetRegistered leaf targets (if configured).
targetsList of all registered leaf MinecraftTargets for this version.
dependsOn(vararg layers)Makes <mcVersion>:common, <mcVersion>:fabric, and <mcVersion>:neoforge inherit the given shared(...) layers (and their includes & mixins).
expand(vararg pairs) / expand(map)Adds version-specific metadata expansion properties (overrides global graft.expand(...)).
common { ... }Configures <mcVersion>:common (CommonTarget).
fabric { ... }Configures <mcVersion>:fabric (FabricVersionTargetSpec: loaderVersion(...), fabricApi(...), dependencies { ... }, cloche { ... }).
neoforge { ... }Configures <mcVersion>:neoforge (NeoforgeVersionTargetSpec: loaderVersion(...), dependencies { ... }, cloche { ... }).

CombineSpec (combine(name) { ... })​

Properties​

PropertyTypeDefaultDescription
archiveBaseNameProperty<String>"${project.name}-$name"Base filename of the combined JAR.
attachToAssembleProperty<Boolean>trueWires the final combined task into assemble.
classConflictCheckProperty<ConflictMode>ConflictMode.ERRORASM bytecode conflict validation mode (ERROR, WARN, IGNORE).
mixinConflictCheckProperty<ConflictMode>ConflictMode.ERRORMixin config validation mode (ERROR, WARN, IGNORE).
ignoreClassConflictsListProperty<String>[]Class path glob patterns excluded from bytecode conflict checking.
ignoreMixinConfigsListProperty<String>[]Mixin config filenames excluded from mixin validation.
fabricDependsOverridesMapProperty<String, String>{}Overrides applied to fabric.mod.json → depends.
neoforgeDependsOverridesMapProperty<String, String>{}Overrides applied to META-INF/neoforge.mods.toml → [[dependencies.<modId>]] versionRange.
optimizeEnabledProperty<Boolean>trueEnables automatic Machete OptimizeJarsTask when org.redlance.dima_dencep.gradle.machete is applied.

Methods​

MethodDescription
fromVersion(mcVersion)Selects all leaf targets for one Minecraft version.
fromVersions(vararg mcVersions)Selects all leaf targets across multiple Minecraft versions.
fromLoader(loader)Selects all leaf targets for "fabric" or "neoforge".
fromAllTargets()Selects all registered leaf targets across all versions and loaders.
from(vararg targets)Selects explicit Cloche MinecraftTarget instances.
bundle(vararg configurations)Bundles additional Gradle configurations into the ShadowJar (and includes their META-INF/services/** in metadata merging).
ignoreClassConflicts(vararg patterns)Appends class glob patterns to ignoreClassConflicts.
ignoreMixinConfigs(vararg names)Appends mixin config filenames to ignoreMixinConfigs.
fabricDepends(vararg pairs) / fabricDepends(map)Sets fabric.mod.json depends overrides.
neoforgeDepends(vararg pairs) / neoforgeDepends(map)Sets neoforge.mods.toml versionRange overrides.
shadow { ... }Direct customization of the underlying ShadowJar task (relocate, exclude, manifest, etc.).
optimize { ... }Customizes Machete's OptimizeJarsTask when Machete is applied.

Dependency & SourceSet extension helpers (Kotlin DSL)​

Importable from org.redlance.graft:

  • ModuleDependency.excludeMinecraftLibs() — Excludes org.slf4j, it.unimi.dsi:fastutil, io.netty, com.google.code.gson, com.google.guava, and org.joml.
  • ProjectDependency.asGraftLibrary(groupOverride = null) — Requests the <group>:<name>-lib capability on a vanillaLibrary project dependency.
  • DependencyHandler.graftLibrary(project, path) — Creates a project dependency with the vanillaLibrary capability attached.
  • SourceSet.useDir(path) — Sets java to <path>/java and resources to <path>/resources.