Some more work on getting mixins injected into the jar

This commit is contained in:
modmuss50 2017-06-28 13:31:56 +01:00
parent 425a8d2948
commit a37f724fa7
No known key found for this signature in database
GPG key ID: 203A5ED4D3E48BEA
2 changed files with 55 additions and 1 deletions

4
.gitignore vendored
View file

@ -21,4 +21,6 @@ changelog.txt
*.project
*.classpath
.idea/*
java_pid2412.hprof
java_pid2412.hprof
/asmTemp/
/logs/

View file

@ -16,10 +16,15 @@ buildscript {
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
name = 'mojang'
url = 'https://libraries.minecraft.net/'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath "gradle.plugin.net.minecrell:licenser:0.2.1"
classpath 'ASM-Injector:ASM-Injector:1.0.0.25'
}
}
@ -307,7 +312,54 @@ task signJar(type: SignJar, dependsOn: reobfJar) {
}
task asmInjectJar {
doLast {
def cacheFiles = new File(".gradle/asmInjector")
if (!cacheFiles.exists()) {
cacheFiles.mkdirs()
}
//Downloads the maven meta data
def mavenMetadata = new File(cacheFiles, "maven-metadata.xml")
logger.lifecycle("ASMInjector: Downloading reborn core metadata")
FileUtils.copyURLToFile(new URL("http://maven.modmuss50.me/RebornCore/RebornCore-1.12/maven-metadata.xml"), mavenMetadata)
def metadata = new XmlSlurper().parseText(FileUtils.readFileToString(mavenMetadata))
def rcVersion = metadata.versioning.release
def rebornCoreJar = new File(cacheFiles, "${rcVersion}.jar")
def localRCJar = new File(cacheFiles, "RebornCore-1.12-3.1.0-universal.jar")
if (localRCJar.exists()) {
logger.lifecycle("ASMInjector: using local RebornCore")
rebornCoreJar = localRCJar
} else {
logger.lifecycle("ASMInjector: downloading RebornCore")
FileUtils.copyURLToFile(new URL("http://maven.modmuss50.me/RebornCore/RebornCore-1.12/${rcVersion}/RebornCore-1.12-${rcVersion}-dev.jar"), rebornCoreJar)
}
logger.lifecycle("ASMInjector: setting up injector")
def injector = new me.modmuss50.asmInjector.ASMInjector()
injector.addClasspathFile(rebornCoreJar)
injector.addClasspathFile(jar.archivePath)
configurations.forgeGradleMc.collect {
injector.addClasspathFile(it)
}
configurations.compile.collect {
if(!it.getName().contains("RebornCore")){
injector.addClasspathFile(it)
}
}
injector.addTransformer("reborncore.mixin.transformer.MixinTransformer")
injector.callSetupClass("reborncore.mixin.implementations.asmInjector.ASMInjectorSetupClass")
logger.lifecycle("ASMInjector: injecting")
injector.inject(jar.archivePath, jar.archivePath)
logger.lifecycle("ASMInjector: done")
}
}
build.dependsOn signJar
signJar.dependsOn asmInjectJar
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle'