Gradle plugin for Cleanroom Loader development and Cleanroom-targeted mod development. The current release is 0.17.0.
The settings plugin adds the following maven repositories:
- Maven Central
- CleanroomMC (proxies MinecraftForge's maven)
- Mojang Libraries
The project plugin registers the main toolchain and development tasks.
pluginManagement {
repositories {
maven {
url = 'https://maven.cleanroommc.com'
}
gradlePluginPortal()
}
}
plugins {
id 'com.cleanroommc.cleanroomgradle.settings' version '0.17.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0' // If auto-provisioning is needed
}plugins {
id 'java'
id 'com.cleanroommc.cleanroomgradle'
}The plugin stays inert until an environment is registered.
Loader and standalone vanilla development still use
cleanroom.mode = 'loader' and cleanroom.mode = 'vanilla'.
Whereas a mod workspace (userdev) is activated by its dependency:
dependencies {
// Selects Cleanroom version 0.7.0-alpha
implementation cleanroom.userdev('0.7.0-alpha') {
accessTransformers.from('src/main/resources/META-INF/modid_at.cfg') // Optional
}
}A stratum project is selected by cleanroom.stratum { }. See Strata.
cleanroom {
caches {
// Global cache
directory = layout.projectDirectory.dir('.gradle/cleanroom-shared')
// 1.12.2 toolchain cache
versionDirectory = layout.projectDirectory.dir('.gradle/cleanroom-shared/versions/1.12.2')
// Project local generated/intermediate data
localDirectory = layout.buildDirectory.dir('cleanroom_gradle')
// Loader defaults false; other modes default true
discardIntermediates = true
}
mappings {
// Optional editable Tiny v2 source at <directory>/mappings.tiny
namesDirectory = layout.projectDirectory.dir('mappings')
}
loader {
accessTransformers.from('src/main/resources/META-INF/accesstransformer.cfg')
sideAnnotationStrippers.from('src/main/resources/META-INF/side_annotation_stripper.cfg')
intermediateRuns = true
}
}- The unsuffixed vanilla tasks always target Minecraft 1.12.2 and resolve that version through Mojang's launcher manifest into the shared cache.
- Named vanilla environments are the way to work with other Minecraft versions.
- Available in every project mode. Override the Java launcher for a named environment with
javaVersion.
- Available in every project mode. Override the Java launcher for a named environment with
- For several versions in one project, declare them together:
cleanroom {
vanilla {
"1.4.7" {
client {
args '--demo'
maxHeapSize = '2G'
}
server {
args '--custom-server-argument'
}
}
"26.1" {
javaVersion = 25 // Defaults to launcher metadata otherwise
}
}
}Letters, numbers, dots, underscores, and hyphens are accepted in environment names.
An alias can target a different version:
cleanroom {
vanilla {
legacy {
version = '1.4.7'
}
}
}That creates runLegacyClient while targeting Minecraft 1.4.7.
Named environments share downloaded assets and per-version metadata/JARs, but use isolated dependency configurations, extracted natives, and run directories. Launcher metadata supplies each vanilla client's main class and arguments.
Use cleanroom.runs to configure existing runs and create custom runs.
Each short name maps to run followed by the name with its first letter capitalized.
cleanroom {
runs {
client { // Configures existing "runClient"
configure {
username = 'Developer'
jvmArgs '-Dmixin.debug.export=true'
}
}
custom { // Creates new "runCustom"
configure {
username = 'Tester'
maxHeapSize = '3G'
args '--demo'
}
inherit = 'client'
}
}
}inheritcan appear anywhere in the outer block and can reference a run declared later.- The parent supplies its built-in launch setup and its
configureblocks before the child'sconfigureblocks execute. - Inheritance can follow a chain of runs. Each block configures the destination task;
namerefers to that task.
| Runs | Availability |
|---|---|
client, server |
Userdev mode and strata that declare a Cleanroom version |
vanillaClient, vanillaServer |
Any selected project mode |
cleanroomClient, cleanroomServer, cleanroomNsightClient |
Loader mode |
srgClient, srgServer, reobfSrgClient, reobfSrgServer, mcpClient, mcpServer |
Loader mode with loader.intermediateRuns = true |
<name>Client, <name>Server |
A declared named vanilla environment |
Kotlin DSL can use the typed configure overload to access the full task API.
import com.cleanroommc.gradle.api.task.mc.RunMinecraft
cleanroom {
runs {
register("custom") {
inherit.set("client")
configure(RunMinecraft::class.java) {
username.set("Tester")
jvmArgs("-Dexample=true")
}
}
}
}assemble produces both jars in build/libs. Maven uses different classifiers.
| Names | Build Artifact | Maven Artifact |
|---|---|---|
| MCP | <name>-<version>-mcp.jar |
<artifactId>-<version>.jar |
| SRG | <name>-<version>.jar |
<artifactId>-<version>-srg.jar |
The MCP jar is what components.java carries.
from components.javapublishes it as the module's main artifact- A project dependency on this module resolves to it
plugins {
id 'maven-publish'
}
publishing {
publications {
mod(MavenPublication) {
// Publishes the main (MCP named) artifact
from components.java
// If you want to publish the reobfuscated artifact also
artifact(tasks.reobfJar) {
classifier = 'srg'
}
}
}
}Cleanroom 0.8.0+ reads mod.json at the root of a mod jar. Write it by hand in the main resources, or declare it in the buildscript:
cleanroom {
mod {
id = 'modid'
name = 'Example Mod'
summary = 'Example Mod.'
license = 'LGPL-3.0-only'
author 'CleanroomMC'
author('CleanroomMC') { role = 'Owner' }
links.put 'issues', 'https://github.com/example/modid/issues'
requires 'jei', '[4.16,)'
optional('jei') { version = '[4.16,)'; side = 'client' }
mixins.add 'mixins.modid.json'
checkForTamper = true
custom.put 'othermod:tab', [icon: 'minecraft:stone']
}
}writeModDescriptorwrites the file into the main resources. Unset members are left out.versiondefaults to the project version.accessTransformersdefaults to the userdevaccessTransformersfiles that sit atMETA-INF/<name>in the main resources.- The block and a hand-written
mod.jsontogether fail the build. - A hand-written
mod.jsonorstratum.jsonat the resources root has${version}replaced with the project version. Nothing else is expanded, andmcmod.infois untouched.
jar fails with a report for each problem Cleanroom would have with the jar at launch:
| Problem | Fix |
|---|---|
Two concrete classes implement one of Mod, ClientMod, ServerMod, Primer |
Keep one, make the others abstract |
| One class implements two of them | One class per interface |
A class implements one and the jar has no mod.json |
Add mod.json |
The jar holds mod.json and stratum.json |
Remove stratum.json |
mod.json sets primer and no class implements Primer |
Add the Primer, or remove primer |
ModType, FMLAT or MixinConfigs in the manifest beside mod.json |
Move ATs to "accessTransformers" and Mixin configs to "mixins". Cleanroom ignores all three for a Cleanroom mod |
version still holds ${, or is unspecified |
Use ${version}, and set the project version |
A value Cleanroom rejects, such as a bad id, a member of the wrong type, an unknown side or kind, a bare version range, an unnamespaced custom key or an instance path outside the game directory |
As the report says |
reobfJar renames the access transformers that mod.json lists to SRG names, or those FMLAT lists in a jar without mod.json.
With "checkForTamper": true, reobfJar writes META-INF/cleanroom.digest last. Cleanroom marks the mod as modified when the jar's content no longer matches it.
- The MCP jar gets no digest, since Cleanroom skips the check in development.
- A later
reobfJar.doLast, or any step that rewrites the jar afterwards such as signing, leaves the digest stale, and the mod then reads as modified.
A stratum is a jar of data and assets with stratum.json for Cleanroom 0.8.0+. It is a project of its own, without the java plugin:
plugins {
id 'com.cleanroommc.cleanroomgradle'
}
version = '1.0.0'
cleanroom {
stratum('0.8.0') {
id = 'examplepack'
name = 'Example Pack'
priority = 10
}
}src/main/resources/
data/examplepack/recipes/...
assets/examplepack/textures/...
gradlew buildpackssrc/main/resourcesandstratum.jsonintobuild/libs/<archivesName>-<version>.jar.gradlew runClientandgradlew runServerlaunch the selected Cleanroom version with the built pack on the classpath. Usestratum { }if you only need to build the pack.- Without
id, the block only selects the mode, andsrc/main/resources/stratum.jsonhas to exist. - The block takes the members of
cleanroom.mod { }that a stratum allows:id,version,name,summary,description,license,author,contributor,credits,links,art,requires,optional,conflicts,before,after,provides,priority,compatibleSince { saves }andcustom. jarfails when the jar holds nostratum.json, holdsmod.jsonor a.classfile, or has an unresolvedversion.- Applying the
javaplugin fails, and so doescleanroom.stratum { }in a userdev project.
A userdev project runs with the stratum through a project dependency:
dependencies {
runtimeOnly project(':examplepack')
}Name the refmap in gradle.properties to have one generated for the main source set:
cg.userdev.refmap = mixins.modid.refmap.json- The Mixin and MixinExtras annotation processors are added at the versions the selected Cleanroom uses.
- The refmap is written into the class output, so both jars carry it. The Mixin config has to name the same file in
"refmap".
Wrap a SRG-named dependency in deobf(...) to have it deobfuscated before reaching the classpath:
dependencies {
implementation deobf('net.test:other-artifact:1.0.0')
// Local jars work the same way
implementation deobf(files('libs/other-mod.jar'))
implementation deobf(fileTree('libs') { include '*.jar' })
}Any repository Gradle can resolve a module from is supported, as are files(...) and fileTree(...).
A local jar is renamed against Minecraft and Cleanroom only, since a file carries no dependencies of its own.
In loader mode deobf(...) cannot be declared on the main compile classpath, that is implementation,compileOnly or api.
Renaming there needs the SRG-named Cleanroom jar, which is built from the main compile classpath, and that would be a cycle.
Use a runtime or test configuration instead, such as runtimeOnly.
Kotlin DSL cannot see deobf(...) as a bare function inside a dependencies block. Use cleanroom.deobf(...) there instead.
In userdev mode with Cleanroom 0.8.0+, declare libraries on jij to nest them, with their runtime dependencies, into reobfJar output:
dependencies {
jij project(':api')
jij cleanroom.jij.file('libs/x.jar', 'com.foo:x:1.2')
jij deobf('net.test:library:1.0') // nests the SRG jar, compiles against MCP
}
cleanroom {
jij {
acknowledgeAgent 'org.foo:profiler'
acknowledgeSystemLoader 'org.foo:legacy'
}
}jijalso puts the library on the compile and runtime classpaths.- Each jar nests byte-identical at
META-INF/jij/<group>/<name>-<version>[-<classifier>].jar, beside a.metametadata file holding its identity, the version range it accepts and what required it. - Only libraries nest. Mods, Forge mods, coremods and tweakers fail the build when declared, and are skipped with a warning when reached transitively. Declare those on
compileOnlyorruntimeOnlyand require them inmod.json. - Libraries Cleanroom ships fail the build when declared. Every classpath is pinned to Cleanroom's versions, so shade and relocate with Shadow when the mod needs another one.
- A plain jar with no
Maven-Artifactin its manifest needs coordinates fromcleanroom.jij.file. - A userdev subproject nests its
reobfJaroutput. runClientandrunServerhand the same jars to Bedrock as nested sources of the mod.- The POM marks directly declared
jijdependencies optional. gradlew dependencies --configuration jijClasspathshows the graph that is nested.
| Area | Tasks |
|---|---|
| Diagnostics | cleanroomInfo |
| Vanilla | runVanillaClient, runVanillaServer (decompile<name> and run<name>Client/Server for named environments) |
| MCP | importMcpNames |
| Stage Runs | runSrgClient, runSrgServer, runReobfSrgClient, runReobfSrgServer, runMcpClient, runMcpServer enabled via loader.intermediateRuns |
| Loader | setup, runCleanroomClient, runCleanroomServer, universalJar, userdevJar, userdevSourcesJar, sourcesJar, javadocJar, installerJar, publishMmcPackZip |
| Userdev | runClient, runServer, reobfJar |
- Run
./gradlew tasks --allfor the complete pipeline.
Tool configurations use defaults only while empty. Add a dependency to replace a tool without changing task wiring:
dependencies {
decompiler 'example:replacement-decompiler:1.0'
mergetool 'example:replacement-merger:1.0'
accesstransformer 'example:replacement-at:1.0'
installertools 'example:replacement-installer-tools:1.0'
}If the replacement has a different command line, configure the corresponding MavenJarExec task with useDefaultToolArguments = false, mainClass, and args.
These overrides apply in every mode.
A published userdev artifact records its exact source-producing tool coordinates.
./gradlew cleanroomInfoThe report shows the effective mode, Minecraft version, names source, cache paths, configured/default tool versions, intermediate policy, and whether the client JAR, server JAR, and asset index are ready for offline use.
It does not resolve or download tool artifacts.
Before using userdev with --offline, resolve the userdev dependency online once.
For loader and vanilla work, run the relevant setup, download, or client task online once so the shared cache contains version_manifest_v2.json and the selected version's meta.json. downloadAssets --offline validates all indexed objects and reports missing/corrupt assets together with a repair command.
Configuration and task validation failures use Gradle's Problems API.
IDEs and the generated build/reports/problems/problems-report.html receive structured problem IDs, details, locations, and suggested fixes.
Gradle build-cache and configuration-cache support are enabled by this project's defaults.
Expensive deterministic transforms including: decompilation, mappings, access transformation, SAS, and binpatch work declare cacheable inputs and outputs.
cleandeletes the build directory andcaches.localDirectory, but preserves shared Minecraft downloads.cleanCleanroomSharedCacheexplicitly deletes the configured sharedcaches.directory.caches.discardIntermediateswhen set totruedeletes consumed project-local pipeline artifact, cacheable tasks can restore them later.- A file is deleted after the consumers that ran in this build have finished.
For shared CI reuse, configure a Gradle local or remote build cache in the consuming build's settings.gradle; CleanroomGradle does not choose credentials or a cache server for you.
The dependency exposes one normal combined module. Cacheable artifact transforms remap and combine patched
Minecraft with Cleanroom, rebuild the matching patched sources, and select client or server extra resources.
Gradle module metadata carries ordinary compile, runtime, and platform dependencies. userdev/config.json
spec 1 carries only artifact-owned pipeline inputs, paths, identities, hashes, tools, and launch metadata.
IDE import resolves the combined jar on its first sync. No generated local Maven repository, synthetic
module version, module-copy task, or setup invocation is involved. Extra access transformers are transform
inputs, so changing one invalidates the combined artifact in Gradle's transform cache. IDE source lookup uses
the published -sources.jar, while Gradle consumers can still request the attributed sources variant directly.