mirror of
https://github.com/barkeser2002/Tenet.git
synced 2026-09-25 02:19:50 +03:00
786 lines
32 KiB
Groovy
786 lines
32 KiB
Groovy
buildscript {
|
|
repositories {
|
|
mavenLocal()
|
|
maven { url 'https://maven.minecraftforge.net/' }
|
|
mavenCentral()
|
|
}
|
|
dependencies {
|
|
classpath 'net.minecraftforge.gradle:ForgeGradle:3.0.197'
|
|
classpath 'net.minecraftforge.gradleutils:GradleUtils:1.0.24'
|
|
classpath 'org.ow2.asm:asm:7.1'
|
|
classpath 'org.ow2.asm:asm-tree:7.1'
|
|
classpath 'com.github.jponge:lzma-java:1.3'
|
|
}
|
|
}
|
|
|
|
import groovy.json.JsonSlurper
|
|
import groovy.json.JsonBuilder
|
|
|
|
import java.nio.file.Files
|
|
import java.text.SimpleDateFormat
|
|
import java.security.MessageDigest
|
|
import net.minecraftforge.gradle.common.task.DownloadMavenArtifact
|
|
import net.minecraftforge.gradle.common.task.ExtractInheritance
|
|
import net.minecraftforge.gradle.common.task.SignJar
|
|
import net.minecraftforge.gradle.patcher.task.ApplyBinPatches
|
|
import net.minecraftforge.gradle.patcher.task.GenerateBinPatches
|
|
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
|
import org.objectweb.asm.ClassReader
|
|
|
|
plugins {
|
|
id 'org.ajoberstar.grgit' version '4.1.1'
|
|
id 'de.undercouch.download' version '5.6.0'
|
|
id 'com.github.ben-manes.versions' version '0.22.0'
|
|
id 'eclipse'
|
|
}
|
|
|
|
ext {
|
|
JAR_SIGNER = null
|
|
MAPPING_CHANNEL = 'snapshot'
|
|
MAPPING_VERSION = '20171003-1.12'
|
|
MC_VERSION = '1.12.2'
|
|
MCP_VERSION = '20200226.224830'
|
|
POST_PROCESSOR = [
|
|
tool: 'net.minecraftforge:mcpcleanup:2.3.2:fatjar',
|
|
repo: 'https://maven.minecraftforge.net/',
|
|
args: ['--input', '{input}', '--output', '{output}']
|
|
]
|
|
}
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
|
options.compilerArgs.addAll([ '--release' , '8' ])
|
|
}
|
|
|
|
project(':mcp') {
|
|
apply plugin: 'net.minecraftforge.gradle.mcp'
|
|
mcp {
|
|
config = MC_VERSION + '-' + MCP_VERSION
|
|
pipeline = 'joined'
|
|
}
|
|
}
|
|
|
|
project(':clean') {
|
|
evaluationDependsOn(':mcp')
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'net.minecraftforge.gradle.patcher'
|
|
compileJava.sourceCompatibility = compileJava.targetCompatibility = sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
implementation 'net.minecraftforge:mergetool:0.2.3.3:forge'
|
|
}
|
|
|
|
patcher {
|
|
parent = project(':mcp')
|
|
mcVersion = MC_VERSION
|
|
patchedSrc = file('src/main/java')
|
|
|
|
mappings channel: MAPPING_CHANNEL, version: MAPPING_VERSION
|
|
processor = POST_PROCESSOR
|
|
|
|
runs {
|
|
|
|
clean_server {
|
|
taskName 'clean_server'
|
|
|
|
main 'net.minecraft.server.MinecraftServer'
|
|
workingDirectory project.file('run')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
project(':mohist') {
|
|
evaluationDependsOn(':clean')
|
|
apply plugin: 'java-library'
|
|
apply plugin: 'maven-publish'
|
|
apply plugin: 'signing'
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'net.minecraftforge.gradle.patcher'
|
|
apply plugin: 'de.undercouch.download'
|
|
|
|
compileJava.sourceCompatibility = compileJava.targetCompatibility = sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
|
tasks.withType(JavaCompile) {
|
|
options.encoding = 'UTF-8'
|
|
}
|
|
group = 'com.mohistmc'
|
|
|
|
sourceSets {
|
|
main {
|
|
java {
|
|
srcDirs = ["$rootDir/src/main/java"]
|
|
}
|
|
resources {
|
|
srcDirs = ["$rootDir/src/main/resources"]
|
|
}
|
|
}
|
|
test {
|
|
compileClasspath += sourceSets.main.runtimeClasspath
|
|
runtimeClasspath += sourceSets.main.runtimeClasspath
|
|
java {
|
|
srcDirs = ["$rootDir/src/test/java"]
|
|
}
|
|
resources {
|
|
srcDirs = ["$rootDir/src/test/resources"]
|
|
}
|
|
}
|
|
}
|
|
//Eclipse adds the sourcesets twice, once where we tell it to, once in the projects folder. No idea why. So delete them
|
|
eclipse.classpath.file.whenMerged { cls -> cls.entries.removeIf { e -> e instanceof SourceFolder && e.path.startsWith('src/') && !e.path.startsWith('src/main/') } }
|
|
|
|
repositories {
|
|
mavenLocal()
|
|
mavenCentral()
|
|
maven { url 'https://hub.spigotmc.org/nexus/content/groups/public/' }
|
|
maven { url = 'https://libraries.minecraft.net/' }
|
|
maven { url = 'https://maven.minecraftforge.net/' }
|
|
}
|
|
|
|
ext {
|
|
LEGACY_MAJOR = 14 //Legacy versions have a API change prefix
|
|
LEGACY_BUILD = 2848 //Base build number to not conflict with existing build numbers
|
|
BUILD_NUMBER = 0 // LEGACY_BUILD + commit offset, used to mimic unique build from old versions
|
|
|
|
SPEC_VERSION = '23.5' // This is overwritten by git tag, but here so dev time doesnt explode
|
|
MCP_ARTIFACT = project(':mcp').mcp.config
|
|
SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.8.5'
|
|
VERSION_JSON = project(':mcp').file('build/mcp/downloadJson/version.json')
|
|
BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.1.1:fatjar'
|
|
}
|
|
|
|
version = '1.12.2-' + grgit.head().abbreviatedId
|
|
|
|
patcher {
|
|
exc = file("$rootDir/src/main/resources/forge.exc")
|
|
parent = project(':clean')
|
|
patches = file("$rootDir/patches/minecraft")
|
|
patchedSrc = file('src/main/java')
|
|
srgPatches = true
|
|
notchObf = true
|
|
accessTransformer = file("$rootDir/src/main/resources/forge_at.cfg")
|
|
//sideAnnotationStripper = file("$rootDir/src/main/resources/forge.sas")
|
|
processor = POST_PROCESSOR
|
|
|
|
runs {
|
|
forge_server {
|
|
taskName 'forge_server'
|
|
main 'com.mohistmc.MohistMC'
|
|
|
|
environment 'tweakClass', 'net.minecraftforge.fml.common.launcher.FMLServerTweaker'
|
|
environment 'mainClass', 'net.minecraft.launchwrapper.Launch'
|
|
environment 'MC_VERSION', '${MC_VERSION}'
|
|
environment 'MCP_MAPPINGS', '{mcp_mappings}'
|
|
environment 'MCP_TO_SRG', '{mcp_to_srg}'
|
|
environment 'FORGE_GROUP', 'net.minecraftforge'
|
|
environment 'FORGE_VERSION', '14.23.5.2864'
|
|
}
|
|
}
|
|
}
|
|
|
|
ext {
|
|
MANIFESTS = [
|
|
'/': [
|
|
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
|
'GitCommit': grgit.head().abbreviatedId,
|
|
'Git-Branch': '1.12.2'
|
|
] as LinkedHashMap,
|
|
'com/mohistmc/': [
|
|
'Specification-Title': 'Mohist',
|
|
'Specification-Vendor': 'MohistMC',
|
|
'Specification-Version': SPEC_VERSION,
|
|
'Implementation-Title': 'com.mohistmc',
|
|
'Implementation-Version': project.version,
|
|
'Implementation-Vendor': 'MohistMC'
|
|
] as LinkedHashMap
|
|
]
|
|
}
|
|
|
|
applyPatches {
|
|
canonicalizeAccess true
|
|
canonicalizeWhitespace true
|
|
maxFuzz 3
|
|
originalPrefix = '../src-base/minecraft/'
|
|
modifiedPrefix = '../src-work/minecraft/'
|
|
}
|
|
genPatches {
|
|
originalPrefix = '../src-base/minecraft/'
|
|
modifiedPrefix = '../src-work/minecraft/'
|
|
}
|
|
configurations {
|
|
installer {
|
|
transitive = false //Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it.
|
|
}
|
|
api.extendsFrom(installer)
|
|
fmllauncherImplementation.extendsFrom(installer)
|
|
}
|
|
dependencies {
|
|
installer 'org.ow2.asm:asm-debug-all:5.2'
|
|
installer 'net.minecraft:launchwrapper:1.12'
|
|
installer 'org.jline:jline:3.5.1'
|
|
installer 'com.typesafe.akka:akka-actor_2.11:2.3.3'
|
|
installer 'com.typesafe:config:1.3.1'
|
|
installer 'org.scala-lang:scala-actors-migration_2.11:1.1.0'
|
|
installer 'org.scala-lang:scala-compiler:2.11.1'
|
|
installer 'org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2_mc' //We change the version so old installs don't break, as our clone of the jar is different the maven central
|
|
installer 'org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2_mc' // --^
|
|
installer 'org.scala-lang:scala-library:2.11.1'
|
|
installer 'org.scala-lang:scala-parser-combinators_2.11:1.0.1'
|
|
installer 'org.scala-lang:scala-reflect:2.11.1'
|
|
installer 'org.scala-lang:scala-swing_2.11:1.0.1'
|
|
installer 'org.scala-lang:scala-xml_2.11:1.0.2'
|
|
installer 'lzma:lzma:0.0.1'
|
|
installer 'java3d:vecmath:1.5.2'
|
|
installer 'net.sf.trove4j:trove4j:3.0.3'
|
|
installer 'org.apache.maven:maven-artifact:3.5.3'
|
|
installer 'net.sf.jopt-simple:jopt-simple:5.0.3'
|
|
installer 'org.apache.logging.log4j:log4j-api:2.17.1' //TODO: Unpin in 1.18.1 or when Mojang bumps the Log4J version
|
|
installer 'org.apache.logging.log4j:log4j-core:2.17.1' //TODO: Unpin in 1.18.1 or when Mojang bumps the Log4J version
|
|
|
|
installer 'com.googlecode.json-simple:json-simple:1.1.1'
|
|
installer 'org.yaml:snakeyaml:1.19'
|
|
installer 'org.xerial:sqlite-jdbc:3.21.0.1'
|
|
installer 'mysql:mysql-connector-java:5.1.46'
|
|
installer 'io.netty:netty-all:4.1.24.Final'
|
|
installer 'net.md-5:SpecialSource:1.8.5'
|
|
installer 'net.md-5:bungeecord-chat:1.12-SNAPSHOT'
|
|
installer 'org.apache.commons:commons-lang3:3.5'
|
|
installer 'commons-lang:commons-lang:2.6'
|
|
compile 'org.jetbrains:annotations:18.0.0'
|
|
installer 'jline:jline:2.13'
|
|
|
|
installer "org.slf4j:slf4j-api:1.7.30"
|
|
installer "org.slf4j:slf4j-nop:1.7.30"
|
|
|
|
installer 'net.java.dev.jna:jna:4.4.0'
|
|
|
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.0.0'
|
|
testImplementation 'org.junit.vintage:junit-vintage-engine:5.+'
|
|
testImplementation 'org.opentest4j:opentest4j:1.0.0' // needed for junit 5
|
|
testImplementation 'org.hamcrest:hamcrest-all:1.3' // needs advanced matching for list order
|
|
}
|
|
|
|
|
|
// We apply the bin patches we just created to make a jar that is JUST our changes
|
|
genClientBinPatches.tool = BINPATCH_TOOL
|
|
task applyClientBinPatches(type: ApplyBinPatches, dependsOn: genClientBinPatches) {
|
|
clean = { genClientBinPatches.cleanJar }
|
|
input = genClientBinPatches.output
|
|
tool = BINPATCH_TOOL
|
|
}
|
|
genServerBinPatches.tool = BINPATCH_TOOL
|
|
genJoinedBinPatches.tool = BINPATCH_TOOL
|
|
task genRuntimeBinPatches(type: GenerateBinPatches, dependsOn: [genClientBinPatches, genServerBinPatches]) {
|
|
tool = BINPATCH_TOOL
|
|
}
|
|
afterEvaluate { p ->
|
|
genRuntimeBinPatches {
|
|
cleanJar = genClientBinPatches.cleanJar
|
|
dirtyJar = genClientBinPatches.dirtyJar
|
|
srg = genClientBinPatches.srg
|
|
patchSets = genClientBinPatches.patchSets
|
|
args = [
|
|
'--output', '{output}',
|
|
'--patches', '{patches}',
|
|
'--srg', '{srg}',
|
|
'--legacy',
|
|
|
|
'--clean', '{clean}',
|
|
'--dirty', '{dirty}',
|
|
'--prefix', 'binpatch/client',
|
|
|
|
'--clean', '{server}',
|
|
'--dirty', '{dirty}',
|
|
'--prefix', 'binpatch/server'
|
|
]
|
|
addExtra('server', genServerBinPatches.cleanJar)
|
|
}
|
|
}
|
|
|
|
task downloadLibraries(dependsOn: ':mcp:setupMCP') {
|
|
inputs.file VERSION_JSON
|
|
doLast {
|
|
def json = new JsonSlurper().parseText(VERSION_JSON.text)
|
|
json.libraries.each {lib ->
|
|
def artifacts = [lib.downloads.artifact] + lib.downloads.get('classifiers', [:]).values()
|
|
artifacts.each{ art ->
|
|
def target = file('build/libraries/' + art.path)
|
|
if (!target.exists()) {
|
|
download {
|
|
src art.url
|
|
dest target
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task extractInheritance(type: ExtractInheritance, dependsOn: [genJoinedBinPatches, downloadLibraries]) {
|
|
input { genJoinedBinPatches.cleanJar }
|
|
doFirst {
|
|
def json = new JsonSlurper().parseText(VERSION_JSON.text)
|
|
json.libraries.each {lib ->
|
|
def artifacts = [lib.downloads.artifact] + lib.downloads.get('classifiers', [:]).values()
|
|
artifacts.each{ art ->
|
|
def target = file('build/libraries/' + art.path)
|
|
if (target.exists())
|
|
addLibrary(target)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
task checkATs(dependsOn: genJoinedBinPatches) {
|
|
inputs.file { genJoinedBinPatches.cleanJar }
|
|
inputs.files patcher.accessTransformers
|
|
doLast {
|
|
def vanilla = [:]
|
|
def zip = new java.util.zip.ZipFile(genJoinedBinPatches.cleanJar)
|
|
zip.entries().findAll { !it.directory && it.name.endsWith('.class') }.each { entry ->
|
|
new ClassReader(zip.getInputStream(entry)).accept(new org.objectweb.asm.ClassVisitor(org.objectweb.asm.Opcodes.ASM7) {
|
|
String name
|
|
void visit(int version, int access, String name, String sig, String superName, String[] interfaces) {
|
|
this.name = name
|
|
vanilla[name] = access
|
|
}
|
|
org.objectweb.asm.FieldVisitor visitField(int access, String name, String desc, String sig, Object value) {
|
|
vanilla[this.name + ' ' + name] = access
|
|
return null
|
|
}
|
|
org.objectweb.asm.MethodVisitor visitMethod(int access, String name, String desc, String sig, String[] excs) {
|
|
vanilla[this.name + ' ' + name + desc] = access
|
|
return null
|
|
}
|
|
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES)
|
|
}
|
|
patcher.accessTransformers.each { f ->
|
|
TreeMap lines = [:]
|
|
f.eachLine { line ->
|
|
def idx = line.indexOf('#')
|
|
if (idx == 0 || line.isEmpty()) return
|
|
def comment = idx == -1 ? null : line.substring(idx)
|
|
if (idx != -1) line = line.substring(0, idx - 1)
|
|
def (modifier, cls, desc) = (line.trim() + ' ').split(' ', -1)
|
|
def key = cls + (desc.isEmpty() ? '' : ' ' + desc)
|
|
def access = vanilla[key.replace('.', '/')]
|
|
if (access == null) {
|
|
if ((desc.equals('*') || desc.equals('*()')) && vanilla[cls.replace('.', '/')] != null)
|
|
println('Warning: ' + line)
|
|
else {
|
|
println('Invalid: ' + line)
|
|
return
|
|
}
|
|
}
|
|
//TODO: Check access actually changes, and expand inheretence?
|
|
lines[key] = [modifier: modifier, comment: comment]
|
|
}
|
|
f.text = lines.collect{ it.value.modifier + ' ' + it.key + (it.value.comment == null ? '' : ' ' + it.value.comment) }.join('\n')
|
|
}
|
|
}
|
|
}
|
|
task checkSAS(dependsOn: extractInheritance) {
|
|
inputs.file { extractInheritance.output }
|
|
inputs.files patcher.sideAnnotationStrippers
|
|
doLast {
|
|
def json = new JsonSlurper().parseText(extractInheritance.output.text)
|
|
|
|
patcher.sideAnnotationStrippers.each { f ->
|
|
def lines = []
|
|
f.eachLine { line ->
|
|
if (line[0] == '\t') return //Skip any tabed lines, those are ones we add
|
|
def idx = line.indexOf('#')
|
|
if (idx == 0 || line.isEmpty()) {
|
|
lines.add(line)
|
|
return
|
|
}
|
|
|
|
def comment = idx == -1 ? null : line.substring(idx)
|
|
if (idx != -1) line = line.substring(0, idx - 1)
|
|
|
|
def (cls, desc) = (line.trim() + ' ').split(' ', -1)
|
|
cls = cls.replaceAll('\\.', '/')
|
|
desc = desc.replace('(', ' (')
|
|
if (desc.isEmpty() || json[cls] == null || json[cls]['methods'] == null || json[cls]['methods'][desc] == null) {
|
|
println('Invalid: ' + line)
|
|
return
|
|
}
|
|
|
|
def mtd = json[cls]['methods'][desc]
|
|
lines.add(cls + ' ' + desc.replace(' ', '') + (comment == null ? '' : ' ' + comment))
|
|
def children = json.values().findAll{ it.methods != null && it.methods[desc] != null && it.methods[desc].override == cls}
|
|
.collect { it.name + ' ' + desc.replace(' ', '') } as TreeSet
|
|
children.each { lines.add('\t' + it) }
|
|
}
|
|
f.text = lines.join('\n')
|
|
}
|
|
}
|
|
}
|
|
|
|
task launcherJson(dependsOn: ['signUniversalJar']) {
|
|
inputs.file { universalJar.archivePath }
|
|
ext {
|
|
output = file('build/version.json')
|
|
vanilla = project(':mcp').file('build/mcp/downloadJson/version.json')
|
|
timestamp = dateToIso8601(new Date())
|
|
comment = [
|
|
"Please do not automate the download and installation of Forge.",
|
|
"Our efforts are supported by ads from the download page.",
|
|
"If you MUST automate this, please consider supporting the project through https://www.patreon.com/LexManos/"
|
|
]
|
|
def idx = project.version
|
|
id = project.version
|
|
}
|
|
inputs.file vanilla
|
|
outputs.file output
|
|
doLast {
|
|
def json_vanilla = new JsonSlurper().parseText(vanilla.text)
|
|
def json = [
|
|
_comment_: comment,
|
|
id: id,
|
|
time: timestamp,
|
|
releaseTime: timestamp,
|
|
type: 'release',
|
|
mainClass: 'net.minecraft.launchwrapper.Launch',
|
|
inheritsFrom: MC_VERSION,
|
|
logging: {},
|
|
minecraftArguments: [
|
|
'--username', '${auth_player_name}',
|
|
'--version', '${version_name}',
|
|
'--gameDir', '${game_directory}',
|
|
'--assetsDir', '${assets_root}',
|
|
'--assetIndex', '${assets_index_name}',
|
|
'--uuid', '${auth_uuid}',
|
|
'--accessToken', '${auth_access_token}',
|
|
'--userType', '${user_type}',
|
|
'--tweakClass', 'net.minecraftforge.fml.common.launcher.FMLTweaker',
|
|
'--versionType', 'Forge'
|
|
].join(' '),
|
|
libraries: [
|
|
[
|
|
//Package our universal jar as the 'main' jar Mojang's launcher loads. It will in turn load Forge's regular jars itself.
|
|
name: "${project.group}:${project.name}:${project.version}",
|
|
downloads: [
|
|
artifact: [
|
|
path: "${project.group.replace('.', '/')}/${project.name}/${project.version}/${project.name}-${project.version}.jar",
|
|
url: "", //Do not include the URL so that the installer/launcher won't grab it. This is also why we don't have the universal classifier
|
|
sha1: sha1(universalJar.archivePath),
|
|
size: universalJar.archivePath.length()
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
|
|
def artifacts = getArtifacts(project, project.configurations.installer, false)
|
|
artifacts.each { key, lib ->
|
|
json.libraries.add(lib)
|
|
}
|
|
|
|
output.text = new JsonBuilder(json).toPrettyString()
|
|
}
|
|
}
|
|
|
|
task installerJson(dependsOn: [launcherJson, genClientBinPatches/*, createClientSRG, createServerSRG*/]) {
|
|
ext {
|
|
output = file('build/install_profile.json')
|
|
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.1.4'
|
|
}
|
|
inputs.file universalJar.archiveFile
|
|
inputs.file genClientBinPatches.toolJar
|
|
inputs.file launcherJson.output
|
|
outputs.file output
|
|
doLast {
|
|
def libs = [
|
|
"${project.group}:${project.name}:${project.version}": [
|
|
name: "${project.group}:${project.name}:${project.version}",
|
|
downloads: [
|
|
artifact: [
|
|
path: "${project.group.replace('.', '/')}/${project.name}/${project.version}/${project.name}-${project.version}.jar",
|
|
url: "", //Do not include the URL so that the installer/launcher won't grab it. This is also why we don't have the universal classifier
|
|
sha1: sha1(universalJar.archivePath),
|
|
size: universalJar.archivePath.length()
|
|
]
|
|
]
|
|
]
|
|
]
|
|
def json = [
|
|
_comment_: launcherJson.comment,
|
|
spec: 0,
|
|
profile: project.name,
|
|
version: launcherJson.id,
|
|
icon: "data:image/png;base64," + new String(Base64.getEncoder().encode(Files.readAllBytes(rootProject.file("icon.ico").toPath()))),
|
|
json: '/version.json',
|
|
path: "${project.group}:${project.name}:${project.version}",
|
|
logo: '/big_logo.png',
|
|
minecraft: MC_VERSION,
|
|
welcome: "Welcome to the simple ${project.name.capitalize()} installer.",
|
|
data: [
|
|
] as Map,
|
|
processors: [
|
|
]
|
|
]
|
|
getClasspath(project, libs, MCP_ARTIFACT.descriptor) //Tell it to download mcp_config
|
|
json.libraries = libs.values().sort{a,b -> a.name.compareTo(b.name)}
|
|
|
|
output.text = new JsonBuilder(json).toPrettyString()
|
|
}
|
|
}
|
|
|
|
task extractObf2Srg(type:net.minecraftforge.gradle.common.task.ExtractMCPData, dependsOn: [':mcp:downloadConfig']) {
|
|
config = project(':mcp').downloadConfig.output
|
|
}
|
|
|
|
task deobfDataLzma(dependsOn: [extractObf2Srg]) {
|
|
ext {
|
|
output_srg = file('build/deobfDataLzma/data.srg')
|
|
output = file('build/deobfDataLzma/data.lzma')
|
|
}
|
|
inputs.file extractObf2Srg.output
|
|
outputs.file output
|
|
doLast {
|
|
net.minecraftforge.gradle.common.util.MappingFile.load(extractObf2Srg.output)
|
|
.write(net.minecraftforge.gradle.common.util.MappingFile.Format.SRG, output_srg)
|
|
|
|
output_srg.withInputStream { ins ->
|
|
output.withOutputStream { outs ->
|
|
def lz = new lzma.streams.LzmaOutputStream.Builder(outs).useEndMarkerMode(true).build()
|
|
|
|
def i = -1
|
|
def buf = new byte[0x100]
|
|
while ((i = ins.read(buf)) != -1)
|
|
lz.write(buf, 0, i)
|
|
|
|
lz.close()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task downloadInstaller(type: DownloadMavenArtifact) {
|
|
artifact = 'net.minecraftforge:installer:2.2.7:fatjar'
|
|
changing = true
|
|
}
|
|
|
|
task downloadMultipleFiles(type: Download) {
|
|
src([
|
|
'https://maven.mohistmc.com/libraries/1.12.2/mohist/libraries.zip'
|
|
])
|
|
dest layout.buildDirectory.dir("libraries")
|
|
}
|
|
|
|
universalJar {
|
|
archiveClassifier = 'server'
|
|
dependsOn(deobfDataLzma)
|
|
dependsOn(downloadMultipleFiles)
|
|
from(deobfDataLzma.output){
|
|
rename{"deobfuscation_data-${MC_VERSION}.lzma"}
|
|
}
|
|
dependsOn(genRuntimeBinPatches)
|
|
from(genRuntimeBinPatches.output) {
|
|
rename{'binpatches.pack.lzma'}
|
|
}
|
|
|
|
configurations.installer.resolvedConfiguration.resolvedArtifacts.collect {
|
|
def moduleVersion = it.moduleVersion
|
|
from (it.file) {
|
|
into ("META-INF/libraries/${moduleVersion.id.group.replace('.', '/')}/${moduleVersion.id.name}/${moduleVersion.id.version}/")
|
|
}
|
|
}
|
|
|
|
from(zipTree(downloadMultipleFiles.outputs.getFiles().asPath)) {
|
|
into 'META-INF/libraries'
|
|
}
|
|
|
|
doFirst {
|
|
def classpath = new StringBuilder()
|
|
def artifacts = getArtifacts(project, project.configurations.installer, false)
|
|
artifacts.each { key, lib ->
|
|
classpath.append("libraries/${lib.downloads.artifact.path} ")
|
|
}
|
|
MANIFESTS.each{ pkg, values ->
|
|
if (pkg == '/') {
|
|
manifest.attributes(values += [
|
|
'Manifest-Version': '2.0',
|
|
'Main-Class': 'com.mohistmc.MohistMC',
|
|
'Class-Path': classpath.toString(),
|
|
'Tweak-Class': 'net.minecraftforge.fml.common.launcher.FMLTweaker'
|
|
])
|
|
} else {
|
|
manifest.attributes(values, pkg)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task installerJar(type: Zip, dependsOn: [downloadInstaller, installerJson, launcherJson, genClientBinPatches, genServerBinPatches, 'signUniversalJar']) {
|
|
archiveClassifier = 'installer'
|
|
archiveExtension = 'jar' //Needs to be Zip task to not override Manifest, so set extension
|
|
destinationDirectory = file('build/libs')
|
|
|
|
from(rootProject.file('/src/main/resources/mohist_logo.png')) {
|
|
rename{'big_logo.png'}
|
|
}
|
|
from(rootProject.file('/src/main/resources/url.png'))
|
|
from(universalJar) {
|
|
into("/maven/${project.group.replace('.', '/')}/${project.name}/${project.version}/")
|
|
rename{"${project.name}-${project.version}.jar"}
|
|
}
|
|
from(installerJson.output)
|
|
from(launcherJson.output)
|
|
from(zipTree(downloadInstaller.output)) {
|
|
duplicatesStrategy = 'exclude'
|
|
}
|
|
}
|
|
|
|
[universalJar, installerJar].each { t ->
|
|
task "sign${t.name.capitalize()}"(type: SignJar, dependsOn: t) {
|
|
onlyIf {
|
|
JAR_SIGNER != null && t.state.failure == null
|
|
}
|
|
def jarsigner = JAR_SIGNER == null ? [:] : JAR_SIGNER
|
|
alias = 'forge'
|
|
storePass = jarsigner.storepass
|
|
keyPass = jarsigner.keypass
|
|
keyStore = jarsigner.keystore
|
|
inputFile = t.archivePath
|
|
outputFile = t.archivePath
|
|
doFirst {
|
|
project.logger.lifecycle('Signing: ' + inputFile)
|
|
}
|
|
}
|
|
t.finalizedBy(tasks.getByName("sign${t.name.capitalize()}"))
|
|
}
|
|
|
|
userdevConfig {
|
|
def artifacts = getArtifacts(project, project.configurations.installer, true)
|
|
artifacts.each { key, lib ->
|
|
addLibrary(lib.name)
|
|
}
|
|
addLibrary('net.minecraftforge:legacydev:0.2.3.+:fatjar')
|
|
addUniversalFilter('^(?!binpatches\\.pack\\.lzma$).*$')
|
|
|
|
runs {
|
|
server {
|
|
main 'net.minecraftforge.legacydev.MainServer'
|
|
|
|
environment 'tweakClass', 'net.minecraftforge.fml.common.launcher.FMLServerTweaker'
|
|
environment 'mainClass', 'net.minecraft.launchwrapper.Launch'
|
|
environment 'MC_VERSION', '${MC_VERSION}'
|
|
environment 'MCP_MAPPINGS', '{mcp_mappings}'
|
|
environment 'MCP_TO_SRG', '{mcp_to_srg}'
|
|
environment 'FORGE_GROUP', "${project.group}"
|
|
environment 'FORGE_VERSION', "14.23.5.2864"
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.eclipse.dependsOn('genEclipseRuns')
|
|
|
|
if (project.hasProperty('UPDATE_MAPPINGS')) {
|
|
extractRangeMap {
|
|
sources sourceSets.test.java.srcDirs
|
|
}
|
|
applyRangeMap {
|
|
sources sourceSets.test.java.srcDirs
|
|
}
|
|
sourceSets.test.java.srcDirs.each { extractMappedNew.addTarget it }
|
|
}
|
|
}
|
|
|
|
def dateToIso8601(date) {
|
|
def format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
|
|
def result = format.format(date)
|
|
return result[0..21] + ':' + result[22..-1]
|
|
}
|
|
|
|
def sha1(file) {
|
|
MessageDigest md = MessageDigest.getInstance('SHA-1')
|
|
file.eachByte 4096, {bytes, size ->
|
|
md.update(bytes, 0, size)
|
|
}
|
|
return md.digest().collect {String.format "%02x", it}.join()
|
|
}
|
|
|
|
def artifactTree(project, artifact) {
|
|
if (!project.ext.has('tree_resolver'))
|
|
project.ext.tree_resolver = 1
|
|
def cfg = project.configurations.create('tree_resolver_' + project.ext.tree_resolver++)
|
|
def dep = project.dependencies.create(artifact)
|
|
cfg.dependencies.add(dep)
|
|
def files = cfg.resolve()
|
|
return getArtifacts(project, cfg, true)
|
|
}
|
|
|
|
def getArtifacts(project, config, classifiers) {
|
|
def ret = [:]
|
|
config.resolvedConfiguration.resolvedArtifacts.each {
|
|
def art = [
|
|
group: it.moduleVersion.id.group,
|
|
name: it.moduleVersion.id.name,
|
|
version: it.moduleVersion.id.version,
|
|
classifier: it.classifier,
|
|
extension: it.extension,
|
|
file: it.file
|
|
]
|
|
def key = art.group + ':' + art.name
|
|
def folder = "${art.group.replace('.', '/')}/${art.name}/${art.version}/"
|
|
def filename = "${art.name}-${art.version}"
|
|
if (art.classifier != null)
|
|
filename += "-${art.classifier}"
|
|
filename += ".${art.extension}"
|
|
def path = "${folder}${filename}"
|
|
def url = "https://libraries.minecraft.net/${path}"
|
|
if (!checkExists(url)) {
|
|
url = "https://maven.minecraftforge.net/${path}"
|
|
if (!checkExists(url)) {
|
|
url = "https://hub.spigotmc.org/nexus/content/groups/public/${path}"
|
|
}
|
|
}
|
|
//TODO remove when Mojang launcher is updated
|
|
if (!classifiers && art.classifier != null) { //Mojang launcher doesn't currently support classifiers, so... move it to part of the version, and force the extension to 'jar'
|
|
art.version = "${art.version}-${art.classifier}"
|
|
art.classifier = null
|
|
art.extension = 'jar'
|
|
path = "${art.group.replace('.', '/')}/${art.name}/${art.version}/${art.name}-${art.version}.jar"
|
|
}
|
|
ret[key] = [
|
|
name: "${art.group}:${art.name}:${art.version}" + (art.classifier == null ? '' : ":${art.classifier}") + (art.extension == 'jar' ? '' : "@${art.extension}"),
|
|
downloads: [
|
|
artifact: [
|
|
path: path,
|
|
url: url,
|
|
sha1: sha1(art.file),
|
|
size: art.file.length()
|
|
]
|
|
]
|
|
]
|
|
}
|
|
return ret
|
|
}
|
|
|
|
def checkExists(url) {
|
|
def code = new URL(url).openConnection().with {
|
|
requestMethod = 'HEAD'
|
|
connect()
|
|
responseCode
|
|
}
|
|
return code == 200
|
|
}
|
|
|
|
def getClasspath(project, libs, artifact) {
|
|
def ret = []
|
|
artifactTree(project, artifact).each { key, lib ->
|
|
libs[lib.name] = lib
|
|
if (lib.name != artifact)
|
|
ret.add(lib.name)
|
|
}
|
|
return ret
|
|
}
|
|
|
|
task setup() {
|
|
dependsOn ':clean:extractMapped'
|
|
dependsOn ':mohist:extractMapped' //These must be strings so that we can do lazy resolution. Else we need evaluationDependsOnChildren above
|
|
} |