Last active
February 14, 2022 19:20
-
-
Save ZekerZhayard/d609437b072927c8d82f5402bdaf0673 to your computer and use it in GitHub Desktop.
build.gradle with Mixin for ForgeGradle 5+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Without MixinGradle | |
// Add below contents to the end of your build.gradle | |
configurations { | |
library | |
implementation.extendsFrom library | |
} | |
repositories { | |
maven { url = "https://repo.spongepowered.org/repository/maven-public/" } | |
} | |
dependencies { | |
library "org.spongepowered:mixin:0.8.4-SNAPSHOT" | |
library "com.google.guava:guava:21.0" | |
annotationProcessor "org.spongepowered:mixin:0.8.4-SNAPSHOT" | |
} | |
minecraft.runs.all { | |
lazyToken("minecraft_classpath") { | |
configurations.library.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator) | |
} | |
} | |
afterEvaluate { | |
def reobfTsrgFile = file("${tasks.reobfJar.temporaryDir}/mixins.tsrg") | |
def refMapFile = file("${tasks.compileJava.temporaryDir}/mixins.examplemod.refmap.json") | |
configurations.compileClasspath.resolvedConfiguration.firstLevelModuleDependencies.each { dep -> | |
dependencies.annotationProcessor([group: dep.moduleGroup, name: dep.moduleName, version: dep.moduleVersion]) | |
} | |
tasks.compileJava { | |
options.compilerArgs += [ | |
"-AreobfTsrgFile=${buildDir.canonicalPath}/createMcpToSrg/output.tsrg", | |
"-AoutTsrgFile=${reobfTsrgFile.canonicalPath}", | |
"-AoutRefMapFile=${refMapFile.canonicalPath}", | |
"-AmappingTypes=tsrg" | |
] | |
dependsOn("createMcpToSrg") | |
doFirst { | |
reobfTsrgFile.delete() | |
refMapFile.delete() | |
} | |
} | |
tasks.jar.from refMapFile | |
tasks.reobfJar { | |
mappings = reobfTsrgFile | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// With MixinGradle | |
// Modify the buildscript closure in your build.gradle | |
buildscript { | |
repositories { | |
maven { url = "https://maven.minecraftforge.net/" } | |
maven { url = "https://repo.spongepowered.org/repository/maven-public/" } | |
mavenCentral() | |
} | |
dependencies { | |
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "5.1.+", changing: true | |
classpath "org.spongepowered:mixingradle:0.7-SNAPSHOT" | |
} | |
} | |
apply plugin: "net.minecraftforge.gradle" | |
// Add below contents to the end of your build.gradle | |
apply plugin: "org.spongepowered.mixin" | |
configurations { | |
library | |
implementation.extendsFrom library | |
} | |
repositories { | |
maven { url = "https://repo.spongepowered.org/repository/maven-public/" } | |
} | |
dependencies { | |
library "org.spongepowered:mixin:0.8.4-SNAPSHOT" | |
library "com.google.guava:guava:21.0" | |
annotationProcessor "org.spongepowered:mixin:0.8.4-SNAPSHOT" | |
} | |
minecraft.runs.all { | |
lazyToken("minecraft_classpath") { | |
configurations.library.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator) | |
} | |
} | |
afterEvaluate { | |
configurations.compileClasspath.resolvedConfiguration.firstLevelModuleDependencies.each { dep -> | |
dependencies.annotationProcessor([group: dep.moduleGroup, name: dep.moduleName, version: dep.moduleVersion]) | |
} | |
} | |
mixin { | |
add sourceSets.main, "mixins.examplemod.refmap.json" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Runtime environment: https://www.curseforge.com/minecraft/mc-mods/mixinbootstrap/files/3437402