1 Star 0 Fork 0

lovehjh / MinecraftForge

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
build.gradle 45.14 KB
一键复制 编辑 原始数据 按行查看 历史
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
buildscript {
repositories {
mavenLocal()
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
//mavenCentral() //TODO: Update Gradle to use HTTPS by default
maven {
name 'maven_central'
url 'https://repo.maven.apache.org/maven2/'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:3.0.187'
classpath 'org.ow2.asm:asm:9.0'
classpath 'org.ow2.asm:asm-tree:9.0'
}
}
import groovy.json.JsonBuilder
import java.nio.file.Files
import java.util.Date
import java.util.LinkedHashMap
import net.minecraftforge.forge.tasks.*
import static net.minecraftforge.forge.tasks.Util.*
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.TaskReobfuscateJar
import net.minecraftforge.gradle.userdev.tasks.RenameJar
import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.plugins.ide.eclipse.model.SourceFolder
plugins {
id 'net.minecrell.licenser' version '0.4'
id 'org.ajoberstar.grgit' version '3.1.1'
id 'com.github.ben-manes.versions' version '0.22.0'
}
apply plugin: 'eclipse'
Util.init() //Init all our extension methods!
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
ext {
JAR_SIGNER = null
if (project.hasProperty('keystore')) {
JAR_SIGNER = [
storepass: project.properties.keystoreStorePass,
keypass: project.properties.keystoreKeyPass,
keystore: project.properties.keystore
]
}
MAPPING_CHANNEL = 'snapshot'
MAPPING_VERSION = '20201028-1.16.3'
MC_VERSION = '1.16.5'
MCP_VERSION = '20210115.111550'
}
project(':mcp') {
apply plugin: 'net.minecraftforge.gradle.mcp'
repositories {
mavenLocal()
}
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 {
mavenLocal()
//mavenCentral() //TODO: Update Gradle to use HTTPS by default
maven {
name 'maven_central'
url 'https://repo.maven.apache.org/maven2/'
}
}
dependencies {
implementation 'net.minecraftforge:forgespi:2.0.+'
}
patcher {
parent = project(':mcp')
mcVersion = MC_VERSION
patchedSrc = file('src/main/java')
mappings channel: MAPPING_CHANNEL, version: MAPPING_VERSION
runs {
clean_client {
taskName 'clean_client'
main 'net.minecraft.client.main.Main'
workingDirectory project.file('run')
args '--gameDir', '.'
args '--version', MC_VERSION
args '--assetsDir', downloadAssets.output
args '--assetIndex', '{asset_index}'
args '--accessToken', '0'
}
clean_server {
taskName 'clean_server'
main 'net.minecraft.server.Main'
workingDirectory project.file('run')
}
}
}
}
project(':forge') {
evaluationDependsOn(':clean')
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply plugin: 'net.minecraftforge.gradle.patcher'
apply plugin: 'net.minecrell.licenser'
compileJava.sourceCompatibility = compileJava.targetCompatibility = sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
group = 'net.minecraftforge'
sourceSets {
fmllauncher {
java {
srcDirs = ["$rootDir/src/fmllauncher/java"]
}
resources {
srcDirs = ["$rootDir/src/fmllauncher/resources"]
}
}
main {
compileClasspath += sourceSets.fmllauncher.runtimeClasspath
runtimeClasspath += sourceSets.fmllauncher.runtimeClasspath
java {
srcDirs = ["$rootDir/src/main/java"]
}
resources {
srcDirs = [
"$rootDir/src/main/resources",
"$rootDir/src/generated/resources"
]
}
}
test {
compileClasspath += sourceSets.fmllauncher.runtimeClasspath
runtimeClasspath += sourceSets.fmllauncher.runtimeClasspath
java {
srcDirs = [
"$rootDir/src/test/java",
"$rootDir/src/fmllaunchertest/java"
]
}
resources {
srcDirs = [
"$rootDir/src/test/resources",
"$rootDir/src/generated_test/resources"
]
}
}
userdev {
compileClasspath += sourceSets.main.runtimeClasspath
runtimeClasspath += sourceSets.main.runtimeClasspath
java {
srcDirs = ["$rootDir/src/userdev/java"]
}
resources {
srcDirs = ["$rootDir/src/userdev/resources"]
}
}
userdev_test {
compileClasspath += sourceSets.userdev.runtimeClasspath
runtimeClasspath += sourceSets.userdev.runtimeClasspath
compileClasspath += sourceSets.test.runtimeClasspath
runtimeClasspath += sourceSets.test.runtimeClasspath
}
}
//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() //TODO: Update Gradle to use HTTPS by default
maven {
name 'maven_central'
url 'https://repo.maven.apache.org/maven2/'
}
}
ext {
SPEC_VERSION = '36.0' // This is overwritten by git tag, but here so dev time doesnt explode
// The new versioning sceme is <MCVersion>-<ForgeMC>.<RB>.<CommitsSinceRB>
// ForgeMC is a unique identifier for every MC version we have supported.
// Essentially, the same as the old, except dropping the first number, and the builds are no longer unique.
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.0.12:fatjar'
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.1.11'
}
def getVersion = {
//TAG-offset-hash
def raw = grgit.describe(longDescr: true, tags:true)
def desc = (raw == null ? '0.0-0-unknown' : grgit.describe(longDescr: true, tags:true)).split('-') as List
def hash = desc.remove(desc.size() - 1)
def offset = desc.remove(desc.size() - 1)
def tag = desc.join('-')
def branch = grgit.branch.current().name
if (branch in ['master', 'HEAD', MC_VERSION, MC_VERSION + '.0'])
branch = null
if (branch != null && branch.endsWith('.x') && MC_VERSION.startsWith(branch.substring(0, branch.length() - 2))) //1.13.x
branch = null
SPEC_VERSION = tag
return "${MC_VERSION}-${tag}.${offset}${t -> if (branch != null) t << '-' + branch}".toString() //Bake the response instead of making it dynamic
}
version = getVersion()
println('Forge Version: ' + version)
patcher {
exc = file("$rootDir/src/main/resources/forge.exc")
parent = project(':clean')
patches = file("$rootDir/patches/minecraft")
patchedSrc = file('src/main/java')
srgPatches = true
accessTransformer = file("$rootDir/src/main/resources/META-INF/accesstransformer.cfg")
sideAnnotationStripper = file("$rootDir/src/main/resources/forge.sas")
runs {
forge_client {
taskName 'forge_client'
main 'net.minecraftforge.userdev.LaunchTesting'
workingDirectory project.file('run')
environment 'target', 'fmldevclient'
environment 'assetIndex', '{asset_index}'
environment 'assetDirectory', downloadAssets.output
environment 'nativesDirectory', extractNatives.output
environment 'MC_VERSION', MC_VERSION
environment 'MCP_VERSION', MCP_VERSION
environment 'FORGE_GROUP', project.group
environment 'FORGE_SPEC', SPEC_VERSION
environment 'FORGE_VERSION', project.version.substring(MC_VERSION.length() + 1).toString()
environment 'LAUNCHER_VERSION', SPEC_VERSION
property 'org.lwjgl.system.SharedLibraryExtractDirectory', 'lwjgl_dll'
property 'eventbus.checkTypesOnDispatch', 'true'
ideaModule "${rootProject.name}.${project.name}.userdev"
mods {
forge { source sourceSets.main }
}
}
forge_test_client {
parent runs.forge_client
taskName 'forge_test_client'
environment 'MOD_CLASSES', 'dummy' // Needed to work around FG limitation, FG will replace this!
ideaModule "${rootProject.name}.${project.name}.userdev_test"
mods {
forge { source sourceSets.main }
tests { sources sourceSets.test }
}
}
forge_server {
taskName 'forge_server'
main 'net.minecraftforge.userdev.LaunchTesting'
workingDirectory project.file('run')
environment 'target', 'fmldevserver'
environment 'MC_VERSION', MC_VERSION
environment 'MCP_VERSION', MCP_VERSION
environment 'FORGE_GROUP', project.group
environment 'FORGE_SPEC', SPEC_VERSION
environment 'FORGE_VERSION', project.version.substring(MC_VERSION.length() + 1).toString()
environment 'LAUNCHER_VERSION', SPEC_VERSION
property 'eventbus.checkTypesOnDispatch', 'true'
ideaModule "${rootProject.name}.${project.name}.userdev"
mods {
forge { source sourceSets.main }
}
}
forge_test_server {
parent runs.forge_server
taskName 'forge_test_server'
environment 'MOD_CLASSES', 'dummy' // Needed to work around FG limitation, FG will replace this!
ideaModule "${rootProject.name}.${project.name}.userdev_test"
mods {
forge { source sourceSets.main }
tests { sources sourceSets.test }
}
}
forge_data {
taskName 'forge_data'
main 'net.minecraftforge.userdev.LaunchTesting'
workingDirectory project.file('run')
environment 'target', 'fmldevdata'
environment 'MC_VERSION', MC_VERSION
environment 'MCP_VERSION', MCP_VERSION
environment 'FORGE_GROUP', project.group
environment 'FORGE_SPEC', SPEC_VERSION
environment 'FORGE_VERSION', project.version.substring(MC_VERSION.length() + 1).toString()
environment 'LAUNCHER_VERSION', SPEC_VERSION
ideaModule "${rootProject.name}.${project.name}.userdev"
mods {
forge { source sourceSets.main }
}
args '--mod', 'forge', '--all', '--output', rootProject.file('src/generated/resources/'), '--validate',
'--existing', sourceSets.main.resources.srcDirs[0]
}
forge_test_data {
parent runs.forge_data
taskName 'forge_test_data'
environment 'MOD_CLASSES', 'dummy' // Needed to work around FG limitation, FG will replace this!
ideaModule "${rootProject.name}.${project.name}.userdev_test"
mods {
tests { sources sourceSets.test }
}
args '--flat', '--all', '--validate',
'--mod', 'data_gen_test',
'--mod', 'piston_event_test',
'--mod', 'global_loot_test',
'--mod', 'scaffolding_test',
'--mod', 'custom_tag_types_test',
'--mod', 'new_model_loader_test',
'--output', rootProject.file('src/generated_test/resources/'),
'--existing', sourceSets.main.resources.srcDirs[0],
'--existing', sourceSets.test.resources.srcDirs[0]
}
}
}
ext {
MANIFESTS = [
'/': [
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'GitCommit': grgit.head().abbreviatedId,
'Git-Branch': grgit.branch.current().getName()
] as LinkedHashMap,
'net/minecraftforge/versions/forge/': [
'Specification-Title': 'Forge',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': SPEC_VERSION,
'Implementation-Title': project.group,
'Implementation-Version': project.version.substring(MC_VERSION.length() + 1),
'Implementation-Vendor': 'Forge Development LLC'
] as LinkedHashMap,
'net/minecraftforge/versions/mcp/': [
'Specification-Title': 'Minecraft',
'Specification-Vendor': 'Mojang',
'Specification-Version': MC_VERSION,
'Implementation-Title': 'MCP',
'Implementation-Version': MCP_VERSION,
'Implementation-Vendor': 'Forge'
] as LinkedHashMap,
'net/minecraftforge/fml/javafmlmod/': [
'Specification-Title': 'Mod Language Provider',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': '1',
'Implementation-Title': 'FML Java Mod',
'Implementation-Version': SPEC_VERSION,
'Implementation-Vendor': 'Forge'
] as LinkedHashMap,
'net/minecraftforge/fml/mclanguageprovider/': [
'Specification-Title': 'Mod Language Provider',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': '1',
'Implementation-Title': 'Minecraft Language Mod Provider',
'Implementation-Version': '1',
'Implementation-Vendor': 'Forge'
] as LinkedHashMap,
'net/minecraftforge/fml/loading/': [
'Specification-Title': 'Launcher',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': '1',
'Implementation-Title': 'FML Launcher',
'Implementation-Version': SPEC_VERSION,
'Implementation-Vendor': 'Forge'
] as LinkedHashMap,
'net/minecraftforge/fml/userdev/': [
'Specification-Title': 'Forge User Development',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': SPEC_VERSION,
'Implementation-Title': project.group,
'Implementation-Version': project.version.substring(MC_VERSION.length() + 1),
'Implementation-Vendor': 'Forge Development LLC'
] as LinkedHashMap
]
}
applyPatches {
canonicalizeAccess true
canonicalizeWhitespace true
maxFuzz 3
}
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:9.0'
installer 'org.ow2.asm:asm-commons:9.0'
installer 'org.ow2.asm:asm-tree:9.0'
installer 'org.ow2.asm:asm-util:9.0'
installer 'org.ow2.asm:asm-analysis:9.0'
installer 'cpw.mods:modlauncher:8.0.9'
installer 'cpw.mods:grossjava9hacks:1.3.+'
installer 'net.minecraftforge:accesstransformers:3.0.1'
installer 'org.antlr:antlr4-runtime:4.9.1' //Dep of AccessTransformer
installer 'net.minecraftforge:eventbus:4.0.+'
installer 'net.minecraftforge:forgespi:3.2.+'
installer 'net.minecraftforge:coremods:4.0.+'
installer 'net.minecraftforge:unsafe:0.2.+'
installer 'com.electronwill.night-config:core:3.6.2'
installer 'com.electronwill.night-config:toml:3.6.2'
installer 'org.jline:jline:3.12.+'
installer 'org.apache.maven:maven-artifact:3.6.0'
installer 'net.jodah:typetools:0.8.+'
installer 'org.apache.logging.log4j:log4j-api:2.11.2'
installer 'org.apache.logging.log4j:log4j-core:2.11.2'
installer 'net.minecrell:terminalconsoleappender:1.2.+'
installer 'net.sf.jopt-simple:jopt-simple:5.0.4'
installer 'org.spongepowered:mixin:0.8.2'
// This is org.openjdk.nashorn:nashorn-core:15.1.1 repackaged so it doesn't crash on JREs < 15.
// See: https://github.com/LexManos/NashornLegacyPackager
installer 'net.minecraftforge:nashorn-core-compat:15.1.1'
fmllauncherImplementation 'com.google.guava:guava:21.0'
fmllauncherImplementation 'com.google.code.gson:gson:2.8.0'
fmllauncherImplementation 'org.lwjgl:lwjgl:3.2.2'
fmllauncherImplementation 'org.lwjgl:lwjgl-glfw:3.2.2'
fmllauncherImplementation 'org.lwjgl:lwjgl-opengl:3.2.2'
fmllauncherImplementation 'org.lwjgl:lwjgl-stb:3.2.2'
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
}
def extraTxts = [
rootProject.file('CREDITS.txt'),
rootProject.file('LICENSE.txt')
]
def changelog = rootProject.file('build/changelog.txt')
if (changelog.exists())
extraTxts += changelog
task crowdin(type: CrowdinTask) {
key = project.hasProperty('crowdinKey') ? project.crowdinKey : null
//TODO: Merge our english.json?
}
// We apply the bin patches we just created to make a jar that is JUST our changes
['Client', 'Server', 'Joined'].each { side ->
def gen = tasks.getByName("gen${side}BinPatches")
gen.tool = BINPATCH_TOOL
task "apply${side}BinPatches"(type: ApplyBinPatches, dependsOn: gen) {
clean = { gen.cleanJar }
input = gen.output
tool = BINPATCH_TOOL
}
def srgTask = tasks.getByName(patcher.notchObf ? 'createMcp2Obf' : 'createMcp2Srg')
// Create SRG named Vanilla jars, using the SpecialSource we have in the installer
task "create${side}SRG"(type: RenameJar, dependsOn: srgTask) {
tool = SPECIAL_SOURCE + ':shaded'
args = ['--stable', '--in-jar', '{input}', '--out-jar', '{output}', '--srg-in', '{mappings}']
mappings = { srgTask.output }
input = { gen.cleanJar }
output = file("build/create${name}SRG/output.jar")
}
}
task downloadLibraries(type: DownloadLibrariesTask, dependsOn: ':mcp:setupMCP') {
input = VERSION_JSON
output = rootProject.file('build/libraries/')
}
task extractInheritance(type: ExtractInheritance, dependsOn: [genJoinedBinPatches, downloadLibraries]) {
tool = INSTALLER_TOOLS + ':fatjar'
input { genJoinedBinPatches.cleanJar }
doFirst { downloadLibraries.libraries.each{ addLibrary(it) } }
}
task findFieldInstanceChecks(type: FieldCompareFinder, dependsOn: ['createJoinedSRG']) {
jar = tasks.getByName('createJoinedSRG').output
output = rootProject.file('src/main/resources/coremods/field_to_instanceof.json')
fields {
bows {
cls = 'net/minecraft/item/Items'
name = 'field_151031_f'
replacement = 'net/minecraft/item/BowItem'
}
crossbows {
cls = 'net/minecraft/item/Items'
name = 'field_222114_py'
replacement = 'net/minecraft/item/CrossbowItem'
}
filled_map {
cls = 'net/minecraft/item/Items'
name = 'field_151098_aY'
replacement = 'net/minecraft/item/FilledMapItem'
blacklist 'net/minecraft/client/gui/screen/inventory/CartographyTableScreen', 'func_230450_a_', '(Lcom/mojang/blaze3d/matrix/MatrixStack;FII)V'
blacklist 'net/minecraft/client/renderer/entity/ItemFrameRenderer', 'func_225623_a_', '(Lnet/minecraft/entity/item/ItemFrameEntity;FFLcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;I)V'
blacklist 'net/minecraft/item/crafting/MapCloningRecipe'
blacklist 'net/minecraft/item/crafting/MapExtendingRecipe'
}
fishing_rod {
cls = 'net/minecraft/item/Items'
name = 'field_151112_aM'
replacement = 'net/minecraft/item/FishingRodItem'
}
shears {
cls = 'net/minecraft/item/Items'
name = 'field_151097_aZ'
replacement = 'net/minecraft/item/ShearsItem'
}
}
}
task checkATs(type: CheckATs, dependsOn: extractInheritance) {
inheritance = extractInheritance.output
ats = patcher.accessTransformers
}
task checkSAS(type: CheckSAS, dependsOn: extractInheritance) {
inheritance = extractInheritance.output
sass = patcher.sideAnnotationStrippers
}
task checkExcs(type: CheckExcs, dependsOn: jar) {
binary = jar.archivePath
excs = patcher.excs
}
task checkAll(dependsOn: [checkATs, checkSAS, checkExcs, findFieldInstanceChecks]){}
task checkPatchesAndFix(type: CheckPatches) {
patchDir = file("$rootDir/patches")
autoFix = true
}
task checkPatches(type: CheckPatches) {
patchDir = file("$rootDir/patches")
autoFix = false
}
project(':forge').getTasks().getByName('genPatches').finalizedBy(checkPatches)
task launcherJson(dependsOn: ['signUniversalJar', 'signLauncherJar']) {
inputs.file universalJar.archivePath
inputs.file { launcherJar.archivePath }
ext {
output = file('build/version.json')
vanilla = project(':mcp').file('build/mcp/downloadJson/version.json')
timestamp = iso8601Now()
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.indexOf('-')
id = project.version.substring(0, idx) + "-${project.name}" + project.version.substring(idx)
}
inputs.file vanilla
outputs.file output
doLast {
def json_vanilla = vanilla.json()
def json = [
_comment_: comment,
id: id,
time: timestamp,
releaseTime: timestamp,
type: 'release',
mainClass: 'cpw.mods.modlauncher.Launcher',
inheritsFrom: MC_VERSION,
logging: {},
arguments: [
game: ['--launchTarget', 'fmlclient', '--fml.forgeVersion', "${project.version.substring(MC_VERSION.length() + 1)}", '--fml.mcVersion', "${MC_VERSION}", '--fml.forgeGroup', "${project.group}", '--fml.mcpVersion', "${MCP_VERSION}"]
],
libraries: [
[
//Package our launcher 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: launcherJar.archivePath.sha1(),
size: launcherJar.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, applyClientBinPatches, applyServerBinPatches/*, createClientSRG, createServerSRG*/]) {
ext {
output = file('build/install_profile.json')
JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.2'
}
doFirst {
ext.BIN_PATCHER = BINPATCH_TOOL.substring(0, BINPATCH_TOOL.length() - 1 - BINPATCH_TOOL.split(':')[3].length())
}
inputs.file applyClientBinPatches.output
inputs.file applyServerBinPatches.output
inputs.file genClientBinPatches.toolJar
inputs.file launcherJson.output
/*
inputs.file createClientSRG.output
inputs.file createServerSRG.output
*/
outputs.file output
doLast {
def libs = [
"${project.group}:${project.name}:${project.version}:universal": [
name: "${project.group}:${project.name}:${project.version}:universal",
downloads: [
artifact: [
path: "${project.group.replace('.', '/')}/${project.name}/${project.version}/${project.name}-${project.version}-universal.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: universalJar.archivePath.sha1(),
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.",
mirrorList: "https://files.minecraftforge.net/mirrors-2.0.json",
data: [
MAPPINGS: [
client: "[${MCP_ARTIFACT.group}:${MCP_ARTIFACT.name}:${MCP_ARTIFACT.version}:mappings@txt]",
server: "[${MCP_ARTIFACT.group}:${MCP_ARTIFACT.name}:${MCP_ARTIFACT.version}:mappings@txt]"
],
BINPATCH: [
client: '/data/client.lzma',
server: '/data/server.lzma'
],
MC_SLIM: [
client: "[net.minecraft:client:${MC_VERSION}-${MCP_VERSION}:slim]",
server: "[net.minecraft:server:${MC_VERSION}-${MCP_VERSION}:slim]"
],
MC_SLIM_SHA: [
client: "'${tasks.getByName('downloadClientSlim').output.sha1()}'",
server: "'${tasks.getByName('downloadServerSlim').output.sha1()}'"
],
MC_EXTRA: [
client: "[net.minecraft:client:${MC_VERSION}-${MCP_VERSION}:extra]",
server: "[net.minecraft:server:${MC_VERSION}-${MCP_VERSION}:extra]"
],
MC_EXTRA_SHA: [
client: "'${tasks.getByName('downloadClientExtra').output.sha1()}'",
server: "'${tasks.getByName('downloadServerExtra').output.sha1()}'"
],
MC_SRG: [
client: "[net.minecraft:client:${MC_VERSION}-${MCP_VERSION}:srg]",
server: "[net.minecraft:server:${MC_VERSION}-${MCP_VERSION}:srg]"
],
/*MC_SRG_SHA: [
client: "'${createClientSRG.output.sha1()}'",
server: "'${createServerSRG.output.sha1()}'"
],*/
PATCHED: [
client: "[${project.group}:${project.name}:${project.version}:client]",
server: "[${project.group}:${project.name}:${project.version}:server]"
],
PATCHED_SHA: [
client: "'${applyClientBinPatches.output.sha1()}'",
server: "'${applyServerBinPatches.output.sha1()}'"
],
MCP_VERSION: [
client: "'${MCP_VERSION}'",
server: "'${MCP_VERSION}'"
]
],
processors: [
[
jar: INSTALLER_TOOLS,
classpath: getClasspath(project, libs, INSTALLER_TOOLS),
args: [
'--task', 'MCP_DATA',
'--input', "[${MCP_ARTIFACT.descriptor}]",
'--output', '{MAPPINGS}',
'--key', 'mappings'
]
], [
jar: JAR_SPLITTER,
classpath: getClasspath(project, libs, JAR_SPLITTER),
args: [
'--input', '{MINECRAFT_JAR}',
'--slim', '{MC_SLIM}',
'--extra', '{MC_EXTRA}',
'--srg', '{MAPPINGS}'
],
outputs: [
'{MC_SLIM}': '{MC_SLIM_SHA}',
'{MC_EXTRA}': '{MC_EXTRA_SHA}'
]
], [
jar: SPECIAL_SOURCE,
classpath: getClasspath(project, libs, SPECIAL_SOURCE),
args: [
//'--stable', Java 9 Is borked, https://bugs.openjdk.java.net/browse/JDK-8184940 TODO: find a fix.
'--in-jar', '{MC_SLIM}',
'--out-jar', '{MC_SRG}',
'--srg-in', '{MAPPINGS}'
]/*,
outputs: [
'{MC_SRG}': '{MC_SRG_SHA}'
]
*/
], [
jar: BIN_PATCHER,
classpath: getClasspath(project, libs, BIN_PATCHER),
args: [
'--clean', '{MC_SRG}',
'--output', '{PATCHED}',
'--apply', '{BINPATCH}'
],
outputs: [
'{PATCHED}': '{PATCHED_SHA}'
]
]
]
]
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()
}
}
['client', 'server'].each { side ->
['slim', 'extra'].each { type ->
def name = "download${side.capitalize()}${type.capitalize()}"
task "${name}"(type: DownloadMavenArtifact) {
artifact = "net.minecraft:${side}:${MC_VERSION}-${MCP_VERSION}:${type}"
}
installerJson.dependsOn(name)
installerJson.inputs.file(tasks.getByName(name).output)
}
}
universalJar {
from extraTxts
// add crowdin locales
from { crowdin.output.exists() ? zipTree(crowdin.output) : null}
dependsOn crowdin
duplicatesStrategy = 'exclude'
doFirst {
MANIFESTS.each{ pkg, values ->
if (pkg == '/') {
manifest.attributes(values)
} else {
manifest.attributes(values, pkg)
}
}
}
}
task launcherJar(type: Jar) {
classifier 'launcher'
from sourceSets.fmllauncher.output
doFirst {
def classpath = new StringBuilder()
def artifacts = getArtifacts(project, project.configurations.installer, false)
artifacts.each { key, lib ->
classpath += "libraries/${lib.downloads.artifact.path} "
}
classpath += "libraries/net/minecraft/server/${MC_VERSION}-${MCP_VERSION}/server-${MC_VERSION}-${MCP_VERSION}-extra.jar"
MANIFESTS.each{ pkg, values ->
if (pkg == '/') {
manifest.attributes(values += [
'Main-Class': 'net.minecraftforge.server.ServerMain',
'Class-Path': classpath.toString(),
'ServerLaunchArgs': [
'--gameDir', '.',
'--launchTarget', 'fmlserver',
'--fml.forgeVersion', "${project.version.substring(MC_VERSION.length() + 1)}".toString(),
'--fml.mcpVersion', MCP_VERSION,
'--fml.mcVersion', MC_VERSION,
'--fml.forgeGroup', project.group
].join(' ')
])
} else {
manifest.attributes(values, pkg)
}
}
}
}
task downloadInstaller(type: DownloadMavenArtifact) {
artifact = 'net.minecraftforge:installer:2.0.+:shrunk'
changing = true
}
task installerJar(type: Zip, dependsOn: [downloadInstaller, installerJson, launcherJson, genClientBinPatches, genServerBinPatches, 'signUniversalJar', 'signLauncherJar']) {
classifier = 'installer'
extension = 'jar' //Needs to be Zip task to not override Manifest, so set extension
destinationDir = file('build/libs')
from(extraTxts)
from(rootProject.file('/installer_logo.png')) {
rename{'big_logo.png'}
}
from(rootProject.file('/src/main/resources/url.png'))
from(genClientBinPatches.output) {
rename{'data/client.lzma'}
}
from(genServerBinPatches.output) {
rename{'data/server.lzma'}
}
from(universalJar) {
into "/maven/${project.group.replace('.', '/')}/${project.name}/${project.version}/"
}
from(launcherJar) {
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, launcherJar, 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()}"))
}
task makeMdk(type: Zip) {
baseName = project.name
classifier = 'mdk'
version = project.version
destinationDir = file('build/libs')
from rootProject.file('gradlew')
from rootProject.file('gradlew.bat')
from extraTxts
from(rootProject.file('gradle/')){
into('gradle/')
}
from(rootProject.file('mdk/')){
rootProject.file('mdk/gitignore.txt').eachLine{
if (!it.trim().isEmpty() && !it.trim().startsWith('#'))
exclude it
}
filter(ReplaceTokens, tokens: [
FORGE_VERSION: project.version,
FORGE_GROUP: project.group,
FORGE_NAME: project.name,
MC_VERSION: MC_VERSION,
MAPPING_CHANNEL: MAPPING_CHANNEL,
MAPPING_VERSION: MAPPING_VERSION,
FORGE_SPEC_VERSION: SPEC_VERSION.split("\\.")[0],
MC_NEXT_VERSION: "1."+((MC_VERSION.split("\\.")[1] as int)+1)
])
rename 'gitignore\\.txt', '.gitignore'
rename 'gitattributes\\.txt', '.gitattributes'
}
}
userdevConfig {
def artifacts = getArtifacts(project, project.configurations.installer, true)
artifacts.each { key, lib ->
addLibrary(lib.name)
}
addLibrary("${project.group}:${project.name}:${project.version}:launcher")
runs {
client {
main 'net.minecraftforge.userdev.LaunchTesting'
environment 'target', 'fmluserdevclient'
environment 'assetIndex', '{asset_index}'
environment 'assetDirectory', '{assets_root}'
environment 'nativesDirectory', '{natives}'
environment 'MC_VERSION', "${MC_VERSION}"
environment 'FORGE_GROUP', "${project.group}"
environment 'MCP_VERSION', "${MCP_VERSION}"
environment 'MOD_CLASSES', '{source_roots}'
environment 'MCP_MAPPINGS', '{mcp_mappings}'
environment 'FORGE_VERSION', "${project.version.substring(MC_VERSION.length() + 1)}"
}
server {
main 'net.minecraftforge.userdev.LaunchTesting'
environment 'target', 'fmluserdevserver'
environment 'MC_VERSION', "${MC_VERSION}"
environment 'FORGE_GROUP', "${project.group}"
environment 'MCP_VERSION', "${MCP_VERSION}"
environment 'MOD_CLASSES', '{source_roots}'
environment 'MCP_MAPPINGS', '{mcp_mappings}'
environment 'FORGE_VERSION', "${project.version.substring(MC_VERSION.length() + 1)}"
}
data {
main 'net.minecraftforge.userdev.LaunchTesting'
environment 'target', 'fmluserdevdata'
environment 'MC_VERSION', "${MC_VERSION}"
environment 'FORGE_GROUP', "${project.group}"
environment 'MCP_VERSION', "${MCP_VERSION}"
environment 'MOD_CLASSES', '{source_roots}'
environment 'MCP_MAPPINGS', '{mcp_mappings}'
environment 'FORGE_VERSION', "${project.version.substring(MC_VERSION.length() + 1)}"
}
}
}
license {
header = file("$rootDir/LICENSE-header.txt")
include 'net/minecraftforge/'
exclude 'net/minecraftforge/server/terminalconsole/'
exclude 'net/minecraftforge/api/' // exclude API here because it's validated in the SPI build
exclude 'net/minecraftforge/fml/common/versioning/ComparableVersion.java'
exclude 'net/minecraftforge/fml/common/versioning/InvalidVersionSpecificationException.java'
exclude 'net/minecraftforge/fml/common/versioning/Restriction.java'
exclude 'net/minecraftforge/fml/common/versioning/VersionRange.java'
exclude 'net/minecraftforge/common/LenientUnboundedMapCodec.java'
tasks {
main {
files = files("$rootDir/src/main/java")
}
test {
files = files("$rootDir/src/test/java")
}
}
}
task userdevExtras(type:Jar) {
dependsOn classes
from sourceSets.userdev.output
classifier 'userdev-temp'
}
task userdevExtrasReobf(type:TaskReobfuscateJar) {
dependsOn userdevExtras, createMcp2Srg
input = tasks.userdevExtras.archivePath
classpath = project.configurations.compile
srg = tasks.createMcp2Srg.output
}
userdevJar {
dependsOn userdevExtrasReobf
from (zipTree(tasks.userdevExtrasReobf.output)) {
into '/inject/'
}
from (sourceSets.userdev.output.resourcesDir) {
into '/inject/'
}
}
extractRangeMap {
addDependencies jar.archivePath
addSources sourceSets.userdev.java.srcDirs
}
applyRangeMap {
setSources sourceSets.userdev.java.srcDirs
}
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 }
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact universalJar
if (changelog.exists()) {
artifact(changelog) {
classifier = 'changelog'
}
}
artifact installerJar
//TODO: installer-win
artifact makeMdk
artifact userdevJar
artifact sourcesJar
artifact launcherJar
pom {
name = 'forge'
description = 'Modifactions to Minecraft to enable mod developers.'
url = 'https://github.com/MinecraftForge/MinecraftForge'
scm {
url = 'https://github.com/MinecraftForge/MinecraftForge'
connection = 'scm:git:git://github.com/MinecraftForge/MinecraftForge.git'
developerConnection = 'scm:git:git@github.com:MinecraftForge/MinecraftForge.git'
}
issueManagement {
system = 'github'
url = 'https://github.com/MinecraftForge/MinecraftForge/issues'
}
licenses {
license {
name = 'LGPL 2.1'
url = 'https://github.com/MinecraftForge/MinecraftForge/blob/1.13-pre/LICENSE.txt'
distribution = 'repo'
}
}
}
}
}
repositories {
maven {
if (project.hasProperty('forgeMavenPassword')) {
credentials {
username project.properties.forgeMavenUser
password project.properties.forgeMavenPassword
}
url 'https://files.minecraftforge.net/maven/manage/upload'
} else {
url 'file://' + rootProject.file('repo').getAbsolutePath()
}
}
}
}
}
//evaluationDependsOnChildren()
task setup() {
dependsOn ':clean:extractMapped'
dependsOn ':forge:extractMapped' //These must be strings so that we can do lazy resolution. Else we need evaluationDependsOnChildren above
}
1
https://gitee.com/lovehjh/MinecraftForge.git
git@gitee.com:lovehjh/MinecraftForge.git
lovehjh
MinecraftForge
MinecraftForge
1.16.x

搜索帮助