Combine all versions into a single tree

This commit is contained in:
Jonas Herzig
2018-02-10 23:35:57 +01:00
parent ec50efec10
commit 748b9da443
95 changed files with 2731 additions and 644 deletions

View File

@@ -0,0 +1,17 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.10.2-12.18.2.2099'
mappings = "snapshot_20160518"
}
dependencies {
shade 'com.github.replaymod:ReplayStudio:7d8c2f7'
shade project(':jGui:versions:1.9.4')
}

View File

@@ -0,0 +1,17 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.11.2-13.20.0.2216'
mappings = "snapshot_20161220"
}
dependencies {
shade 'com.github.replaymod:ReplayStudio:9605121'
shade project(':jGui:versions:1.9.4')
}

View File

@@ -0,0 +1,17 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.11-13.19.1.2188'
mappings = "snapshot_20161111"
}
dependencies {
shade 'com.github.ReplayMod:ReplayStudio:2b063ec'
shade project(':jGui:versions:1.9.4')
}

View File

@@ -0,0 +1,17 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.12.1-14.22.0.2444'
mappings = "snapshot_20170615"
}
dependencies {
shade 'com.github.replaymod:ReplayStudio:9ee698e'
shade project(':jGui:versions:1.12')
}

View File

@@ -0,0 +1,17 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.12.2-14.23.0.2486'
mappings = "snapshot_20170615"
}
dependencies {
shade 'com.github.replaymod:ReplayStudio:b040763'
shade project(':jGui:versions:1.12')
}

View File

@@ -0,0 +1,17 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.12-14.21.1.2387'
mappings = "snapshot_20170615"
}
dependencies {
shade 'com.github.replaymod:ReplayStudio:9ee698e'
shade project(':jGui:versions:1.12')
}

View File

@@ -0,0 +1,17 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.8.9-11.15.1.1722'
mappings = "stable_22"
}
dependencies {
shade 'com.github.replaymod:ReplayStudio:a2168ca'
shade project(':jGui:versions:1.8.9')
}

17
versions/1.8/build.gradle Normal file
View File

@@ -0,0 +1,17 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.8-11.14.4.1563'
mappings = "snapshot_nodoc_20141130"
}
dependencies {
shade 'com.github.replaymod:ReplayStudio:a2168ca'
shade project(':jGui:versions:1.8')
}

View File

@@ -0,0 +1,17 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.9.4-12.17.0.1976'
mappings = "snapshot_20160518"
}
dependencies {
shade 'com.github.replaymod:ReplayStudio:14daa88'
shade project(':jGui:versions:1.9.4')
}

273
versions/common.gradle Normal file
View File

@@ -0,0 +1,273 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.ow2.asm:asm:6.0'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = gitDescribe()
group= "com.replaymod"
archivesBaseName = "replaymod"
minecraft {
coreMod = 'com.replaymod.core.LoadingPlugin'
runDir = "../../eclipse"
replace '@MOD_VERSION@', project.version
}
afterEvaluate {
// Includes intentional whitespace to stop Forge from declaring the mod to be compatible with
// a newer srg-compatible MC version (that may be using a different protocol version)
minecraft.replace '@MC_VERSION@', "[ ${project.minecraft.version} ]"
}
repositories {
maven {
name = "SpongePowered Repo"
url = "http://repo.spongepowered.org/maven/"
}
maven { url 'https://jitpack.io' }
}
configurations {
shade
compile.extendsFrom shade
}
dependencies {
compile 'org.projectlombok:lombok:1.16.4'
compile 'org.spongepowered:mixin:0.7.5-SNAPSHOT'
shade 'com.googlecode.mp4parser:isoparser:1.1.7'
shade 'org.apache.commons:commons-exec:1.3'
def withoutGuava = { exclude group: 'com.google.guava', module: 'guava-jdk5' }
shade 'com.google.apis:google-api-services-youtube:v3-rev178-1.22.0', withoutGuava
shade 'com.google.api-client:google-api-client-gson:1.20.0', withoutGuava
shade 'com.google.api-client:google-api-client-java6:1.20.0', withoutGuava
shade 'com.google.oauth-client:google-oauth-client-jetty:1.20.0'
shade 'org.aspectj:aspectjrt:1.8.2'
testCompile 'junit:junit:4.11'
}
if (project.name != 'core') {
apply from: '../preprocessor.gradle'
def preprocessedSrc = 'build/preprocessed/src'
def preprocessedRes = 'build/preprocessed/res'
def originalSrc = '../../src/main/java'
def originalRes = '../../src/main/resources'
def (major, minor, patch) = project.name.tokenize('.')
def mcVersion = "${major}${minor.padLeft(2, '0')}${(patch ?: '').padLeft(2, '0')}"
def vars = [MC: mcVersion as int]
sourceSets {
main.java.srcDir preprocessedSrc
main.resources.srcDir preprocessedRes
}
task preprocessJava {
inputs.dir(originalSrc)
outputs.dir(preprocessedSrc)
doLast {
project.convertTree(vars, originalSrc, preprocessedSrc)
}
}
task preprocessResources {
inputs.dir(originalRes)
outputs.dir(preprocessedRes)
doLast {
project.convertTree(vars, originalRes, preprocessedRes)
}
}
compileJava.dependsOn preprocessJava
processResources.dependsOn preprocessResources
[deobfMcMCP, deobfMcSRG].each { task ->
task.dependsOn preprocessResources
}
minecraft.accessTransformer preprocessedRes + '/META-INF/replaymod_at.cfg'
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn configurations.compile
dependsOn configurations.shade
def shade = {files(
configurations.compile.findAll {it.name.startsWith 'mixin-'}
+ configurations.shade
)}
def noticeDir = file("$buildDir/NOTICE")
doFirst {
noticeDir.deleteDir()
noticeDir.mkdirs()
shade().collect { it.isDirectory() ? fileTree(it) : zipTree(it) }.each {
it.matching { include '**/NOTICE*' }.each {
new File(noticeDir, 'NOTICE.txt') << it.getText('UTF-8') + '\n'
}
}
}
from noticeDir
from ({shade().collect { it.isDirectory() ? it : zipTree(it) }}) {
exclude '**/NOTICE*'
eachFile {
if (getName() == 'LICENSE.txt') {
setName(getFile().getParentFile().getName().split('.jar_')[0] + '-LICENSE.txt')
}
}
}
manifest {
attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
'TweakOrder': '0',
'FMLCorePluginContainsFMLMod': 'true',
'FMLAT': 'replaymod_at.cfg'
}
}
def gitDescribe() {
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--always', '--dirty=*'
standardOutput = stdout
}
return stdout.toString().trim()
} catch (e) {
return "unknown"
}
}
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version': project.version, 'mcversion': project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
sourceSets {
main {
ext.refMap = "mixins.replaymod.refmap.json"
}
integrationTest {
compileClasspath += main.runtimeClasspath + main.output
java {
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
task copySrg(type: Copy, dependsOn: 'genSrgs') {
from {project.tasks.genSrgs.mcpToSrg}
into 'build'
}
setupDecompWorkspace.dependsOn copySrg
setupDevWorkspace.dependsOn copySrg
project.tasks.idea.dependsOn copySrg
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipOutputStream
import org.objectweb.asm.*
import static org.objectweb.asm.Opcodes.ASM5
// MC binaries were complied with a java version that produces invalid class files under certain circumstances
// This causes setupCIWorkspace to be insufficient for compiling.
// Related JDK bug: https://bugs.openjdk.java.net/browse/JDK-8066725
// As a workaround, to use setupCIWorkspace on Drone, we modify the bin jar in-place and remove all parameter annotations.
// WARNING: This piece of code ignores any and all gradle conventions and will probably fail horribly when run outside
// of a single-use environment (e.g. Drone). Use setupDecompWorkspace for normal use.
tasks.deobfMcMCP.doLast {
println "Applying RuntimeInvisibleParameterAnnotations workaround..."
File jar = getOutJar()
File tmp = new File((File) getTemporaryDir(), "workaround.jar")
tmp.withOutputStream {
new ZipOutputStream(it).withStream { dst ->
new ZipFile(jar).withCloseable { src ->
src.entries().each {
if (it.name.startsWith("net/minecraft/") && it.name.endsWith(".class")) {
def cw = new ClassWriter(0)
def cv = new ClassVisitor(ASM5, cw) {
@Override
MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
return new MethodVisitor(ASM5, cv.visitMethod(access, name, desc, signature, exceptions)) {
@Override
AnnotationVisitor visitParameterAnnotation(int parameter, String pdesc, boolean visible) {
return null // Strip all parameter annotations
}
}
}
}
new ClassReader(src.getInputStream(it)).accept(cv, 0)
dst.putNextEntry(new ZipEntry(it.name))
dst.write(cw.toByteArray())
} else {
dst.putNextEntry(it)
dst.write(src.getInputStream(it).bytes)
}
}
}
}
}
jar.delete()
tmp.renameTo(jar)
}
task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
main = 'GradleStart'
standardOutput = System.out
errorOutput = System.err
workingDir file(minecraft.runDir)
def testDir = new File(minecraft.runDir, "integration-test")
doFirst {
testDir.deleteDir()
testDir.mkdirs()
}
doLast {
testDir.deleteDir()
}
afterEvaluate {
def runClient = tasks.getByName("runClient")
runIntegrationTest.jvmArgs = runClient.jvmArgs + "-Dfml.noGrab=true"
runIntegrationTest.args = runClient.args + "--gameDir" + testDir.canonicalPath
runIntegrationTest.classpath runClient.classpath + sourceSets.integrationTest.output
}
}
defaultTasks 'build'

108
versions/core/build.gradle Normal file
View File

@@ -0,0 +1,108 @@
buildscript {
dependencies {
//#if MC>=10904
//#if MC>=11200
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
//#else
//$$ classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
//#endif
//#else
//#if MC>=10809
//$$ classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
//#else
//$$ classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
//#endif
//#endif
}
}
apply from: '../common.gradle'
sourceSets {
main.java.srcDirs = ['../../src/main/java']
main.resources.srcDirs = ['../../src/main/resources']
}
minecraft {
//#if MC>=11202
version = '1.12.2-14.23.0.2486'
mappings = "snapshot_20170615"
//#else
//#if MC>=11201
//$$ version = '1.12.1-14.22.0.2444'
//$$ mappings = "snapshot_20170615"
//#else
//#if MC>=11200
//$$ version = '1.12-14.21.1.2387'
//$$ mappings = "snapshot_20170615"
//#else
//#if MC>=11102
//$$ version = '1.11.2-13.20.0.2216'
//$$ mappings = "snapshot_20161220"
//#else
//#if MC>=11100
//$$ version = '1.11-13.19.1.2188'
//$$ mappings = "snapshot_20161111"
//#else
//#if MC>=11002
//$$ version = '1.10.2-12.18.2.2099'
//$$ mappings = "snapshot_20160518"
//#else
//#if MC>=10904
//$$ version = '1.9.4-12.17.0.1976'
//$$ mappings = "snapshot_20160518"
//#else
//#if MC>=10809
//$$ version = '1.8.9-11.15.1.1722'
//$$ mappings = "stable_22"
//#else
//$$ version = '1.8-11.14.4.1563'
//$$ mappings = "snapshot_nodoc_20141130"
//#endif
//#endif
//#endif
//#endif
//#endif
//#endif
//#endif
//#endif
}
dependencies {
//#if MC>=11200
//#if MC>=11202
shade 'com.github.replaymod:ReplayStudio:b040763'
//#else
//#if MC>=11201
//$$ shade 'com.github.replaymod:ReplayStudio:d4b2037'
//#else
//$$ shade 'com.github.replaymod:ReplayStudio:9ee698e'
//#endif
//#endif
shade project(':jGui:versions:1.12')
//#else
//#if MC>=10904
//$$ shade project(':jGui:versions:1.9.4')
//#if MC>=11002
//#if MC>=11100
//#if MC>=11102
//$$ shade 'com.github.replaymod:ReplayStudio:9605121'
//#else
//$$ shade 'com.github.ReplayMod:ReplayStudio:2b063ec'
//#endif
//#else
//$$ shade 'com.github.replaymod:ReplayStudio:7d8c2f7'
//#endif
//#else
//$$ shade 'com.github.replaymod:ReplayStudio:14daa88'
//#endif
//#else
//#if MC>=10809
//$$ shade project(':jGui:versions:1.8.9')
//#else
//$$ shade project(':jGui:versions:1.8')
//#endif
//$$ shade 'com.github.replaymod:ReplayStudio:a2168ca'
//#endif
//#endif
}

View File

@@ -0,0 +1,151 @@
static def evalVar(vars, String var) {
if (var.number) {
return var as int
} else {
return vars[var]
}
}
import java.util.regex.Pattern
static def evalExpr(vars, String expr) {
def matcher = Pattern.compile(/(.+)(<=|>=|<|>)(.+)/).matcher(expr)
if (matcher.matches()) {
def lhs = evalVar(vars, matcher.group(1))
def rhs = evalVar(vars, matcher.group(3))
switch (matcher.group(2)) {
case '>=': return lhs >= rhs
case '<=': return lhs <= rhs
case '>': return lhs > rhs
case '<': return lhs < rhs
}
}
}
static def getIndent(String str) {
return str.takeWhile {it == ' '}.length()
}
class ParserException extends RuntimeException {
ParserException(String str) {
super(str)
}
}
static def convertSource(Map<String, String> kws, Map<String, Integer> vars, List<String> lines, String fileName) {
def ifStack = []
List<Integer> indentStack = []
def active = true
def n = 0
lines = lines.collect { line ->
n++
def trimmed = line.trim()
if (trimmed.startsWith(kws.if)) {
def result = evalExpr(vars, trimmed.substring(kws.if.length()))
ifStack.push(result)
if (result != null) {
indentStack.push(getIndent(line))
active &= result
}
} else if (trimmed.startsWith(kws.else)) {
if (ifStack.isEmpty()) {
throw new ParserException("Unexpected else in line $n of $fileName")
}
def head = ifStack.pop()
if (head != null) {
head = !head
indentStack.pop()
indentStack.push(getIndent(line))
}
ifStack.push(head)
active = true;
ifStack.each {
if (it != null) {
active &= it
}
}
} else if (trimmed.startsWith(kws.ifdef)) {
ifStack.push(null)
} else if (trimmed.startsWith(kws.endif)) {
if (ifStack.isEmpty()) {
throw new ParserException("Unexpected endif in line $n of $fileName")
}
def head = ifStack.pop()
if (head != null) {
indentStack.pop()
active = true;
ifStack.each {
if (it != null) {
active &= it
}
}
}
} else {
if (active) {
if (trimmed.startsWith(kws.eval)) {
line = line.replaceFirst(Pattern.quote(kws.eval) + ' ?', '')
if (line.trim().isEmpty()) {
line = ''
}
}
} else {
def currIndent = indentStack.last()
if (trimmed.isEmpty()) {
line = ' ' * currIndent + kws.eval
} else if (!trimmed.startsWith(kws.eval)) {
def actualIndent = getIndent(line)
if (currIndent <= actualIndent) {
line = ' ' * currIndent + kws.eval + ' ' + line.substring(currIndent)
}
}
}
}
line
}
if (!ifStack.isEmpty()) {
throw new ParserException("Missing endif in $fileName")
}
return lines
}
import java.nio.charset.StandardCharsets
static def convertFile(Map<String, String> kws, Map<String, Integer> vars, File inFile, File outFile) {
def string = new String(inFile.readBytes(), StandardCharsets.UTF_8)
def lines = string.readLines()
try {
lines = convertSource(kws, vars, lines, inFile.path)
} catch (e) {
if (e instanceof ParserException) {
throw e
}
throw new RuntimeException("Failed to convert file " + inFile, e)
}
outFile.parentFile.mkdirs()
if (string.endsWith('\n')) {
outFile.write(lines.collect { it + '\n' }.join(''))
} else {
outFile.write(lines.join('\n'))
}
}
project.ext.convertTree = { Map<String, Integer> vars, String inName, String outName=inName ->
def defaultKws = [if: '//#if ', ifdef: '//#ifdef ', else: '//#else', endif: '//#endif', eval: '//$$']
def cfgKws = [if: '##if ', ifdef: '##ifdef ', else: '##else', endif: '##endif', eval: '#$$']
def extensions = ['.java': defaultKws, '.gradle': defaultKws, '.json': defaultKws, '.cfg': cfgKws]
def inPath = project.file(inName).toPath()
def outPath = project.file(outName).toPath()
def inPlace = inPath.toAbsolutePath().equals(outPath.toAbsolutePath())
project.fileTree(inName).forEach { file ->
def outFile = outPath.resolve(inPath.relativize(file.toPath())).toFile()
def kws = extensions.find { ext, _ -> file.name.endsWith(ext) }
if (kws) {
convertFile(kws.value, vars, file, outFile)
} else if (!inPlace) {
copy {
from file
into outFile.parentFile
}
}
}
}