Files
Tenet/build.gradle
2024-08-31 02:50:58 +08:00

874 lines
37 KiB
Groovy

import com.mohistmc.tasks.JenkinsNumber
import net.minecraftforge.forge.tasks.*
import net.minecraftforge.forge.tasks.checks.*
import net.minecraftforge.gradle.common.tasks.*
import net.minecraftforge.gradle.userdev.tasks.RenameJar
import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.plugins.ide.eclipse.model.SourceFolder
import java.nio.file.Files
import java.text.SimpleDateFormat
import java.util.stream.Collectors
import static net.minecraftforge.forge.tasks.Util.*
plugins {
id 'com.github.ben-manes.versions' version '0.46.0'
id 'net.minecraftforge.gradleutils' version '[2.2,2.3)'
id 'eclipse'
id 'de.undercouch.download' version '5.6.0'
id 'net.minecraftforge.gradle.patcher' version '[6.0.16,6.2)' apply false
id 'net.minecraftforge.gradle.mcp' version '[6.0.16,6.2)' apply false
}
init() //Init all our extension methods!
ext {
JAR_SIGNER = null
MAPPING_CHANNEL = 'official'
MAPPING_VERSION = '1.20.1'
MC_VERSION = '1.20.1'
MC_NEXT_VERSION = '1.21'
MCP_VERSION = '20230612.114412'
SNAPSHOT = false
SPI_VERSION = '7.0.1'
MERGETOOL_VERSION = '1.1.5'
ACCESSTRANSFORMERS_VERSION = '8.0.4'
COREMODS_VERSION = '5.1.6'
EVENTBUS_VERSION = '6.0.5'
MODLAUNCHER_VERSION = '10.0.9'
SECUREJARHANDLER_VERSION = 'mohist-2.1.11'
BOOTSTRAPLAUNCHER_VERSION = '1.1.2'
ASM_VERSION = '9.7'
INSTALLER_VERSION = '2.2.+'
MIXIN_VERSION = '0.8.5'
TERMINALCONSOLEAPPENDER_VERSION = '1.4.0'
JLINE_VERSION = '3.21.0'
NIGHTCONFIG_VERSION = '3.6.4'
JETBRAINS_ANNOTATIONS_VERSION = '23.0.0'
SLF4J_API_VERSION = '1.8.0-beta4'
APACHE_MAVEN_ARTIFACT_VERSION = '3.8.5'
JARJAR_VERSION = '0.3.19'
MOJANG_LOGGING_VERSION = '1.1.1'
LOG4J_VERSION = '2.20.0'
GUAVA_VERSION = '31.1-jre'
GSON_VERSION = '2.10'
APACHE_COMMONS_LANG3_VERSION = '3.12.0'
JOPT_SIMPLE_VERSION = '5.0.4'
COMMONS_IO_VERSION = '2.11.0'
GIT_INFO = gradleutils.gitInfo
VERSION = MC_VERSION + "-" + project.forge_version
FORGE_VERSION = project.forge_version
MOHIST_VERSION = JenkinsNumber.info()
ADVENTURE_VERSION = '4.14.0'
SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.11.0'
BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.1.1:fatjar'
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.4.1'
JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4'
FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.22:all'
MIN_TAG_FOR_CHANGELOG = '41.0'
// remove :fatjar
BIN_PATCHER = BINPATCH_TOOL.substring(0, BINPATCH_TOOL.length() - 1 - BINPATCH_TOOL.split(':')[3].length())
}
println('Version: ' + VERSION +
' Java: ' + System.getProperty('java.version') +
' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ')' +
' Arch: ' + System.getProperty('os.arch'))
subprojects {
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply plugin: 'java'
group = 'net.minecraftforge'
version = VERSION
repositories {
mavenLocal()
mavenCentral()
maven {
name = 'forge'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'minecraft'
url = 'https://libraries.minecraft.net/'
}
maven { url = 'https://maven.neoforged.net/releases' }
maven { url 'https://hub.spigotmc.org/nexus/content/groups/public/' }
maven { url 'https://maven.mohistmc.com/' }
maven { url 'https://maven.izzel.io/releases' }
maven { url 'https://repo.extendedclip.com/content/repositories/placeholderapi' }
}
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
options.warnings = false // Shutup deprecated for removal warnings
}
}
project(':mcp') {
apply plugin: 'net.minecraftforge.gradle.mcp'
tasks.withType(AbstractPublishToMaven.class).forEach{tsk -> tsk.enabled = false } // We don't want to publish anything
mcp {
config MC_VERSION + '-' + MCP_VERSION
pipeline = 'joined'
}
}
project(':clean') {
evaluationDependsOn(':mcp')
apply plugin: 'net.minecraftforge.gradle.patcher'
tasks.withType(AbstractPublishToMaven.class).forEach{tsk -> tsk.enabled = false } // We don't want to publish anything
dependencies {
implementation 'net.minecraftforge:forgespi:' + SPI_VERSION
}
patcher {
parent = project(':mcp')
mcVersion = MC_VERSION
patchedSrc = file('src/main/java')
mappings channel: MAPPING_CHANNEL, version: MAPPING_VERSION
runs {
clean_server {
client false
taskName 'clean_server'
ideaModule "${rootProject.name}.${project.name}.main"
main 'net.minecraft.server.Main'
workingDirectory project.file('run')
}
}
}
}
def mohistDeps = {
mohist "com.nothome:javaxdelta:2.0.1"
mohist "com.github.jponge:lzma-java:1.3"
mohist "commons-collections:commons-collections:3.2.2"
mohist "com.opencsv:opencsv:4.4"
mohist "de.siegmar:fastcsv:2.0.0"
mohist "net.minecraftforge:installertools:1.4.1"
mohist 'net.minecraftforge:binarypatcher:1.1.1'
mohist "net.minecraftforge:JarJarFileSystems:0.3.19"
mohist "net.minecraftforge:ForgeAutoRenamingTool:0.1.22:all"
mohist "net.minecraftforge:srgutils:0.5.4"
mohist "net.minecraftforge:jarsplitter:1.1.4"
mohist 'com.google.errorprone:error_prone_annotations:2.1.3'
mohist 'org.apache.commons:commons-text:1.3'
mohist 'org.apache.commons:commons-collections4:4.2'
mohist 'commons-beanutils:commons-beanutils:1.9.3'
mohist "trove:trove:1.0.2"
mohist "org.codehaus.mojo:animal-sniffer-annotations:1.14"
mohist "com.google.j2objc:j2objc-annotations:1.1"
mohist "cpw.mods:bootstraplauncher:1.1.2"
mohist "com.google.code.findbugs:jsr305:3.0.2"
mohist 'org.checkerframework:checker-qual:2.0.0'
}
def sharedDeps = {
moduleonly "cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}"
moduleonly "org.ow2.asm:asm:${ASM_VERSION}"
moduleonly "org.ow2.asm:asm-commons:${ASM_VERSION}"
moduleonly "org.ow2.asm:asm-tree:${ASM_VERSION}"
moduleonly "org.ow2.asm:asm-util:${ASM_VERSION}"
moduleonly "org.ow2.asm:asm-analysis:${ASM_VERSION}"
moduleonly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}"
moduleonly "net.minecraftforge:JarJarFileSystems:${JARJAR_VERSION}"
compileOnly "cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}" // Mmohist TODO
installer "org.ow2.asm:asm:${ASM_VERSION}"
installer "org.ow2.asm:asm-commons:${ASM_VERSION}"
installer "org.ow2.asm:asm-tree:${ASM_VERSION}"
installer "org.ow2.asm:asm-util:${ASM_VERSION}"
installer "org.ow2.asm:asm-analysis:${ASM_VERSION}"
installer "net.minecraftforge:accesstransformers:${ACCESSTRANSFORMERS_VERSION}"
installer 'org.antlr:antlr4-runtime:4.9.1' // Dep of AccessTransformer
installer "net.minecraftforge:forgespi:${SPI_VERSION}"
installer "net.minecraftforge:coremods:${COREMODS_VERSION}"
installer "cpw.mods:modlauncher:${MODLAUNCHER_VERSION}"
installer 'net.minecraftforge:unsafe:0.2.+'
installer "net.minecraftforge:mergetool:${MERGETOOL_VERSION}:api"
installer "com.electronwill.night-config:core:${NIGHTCONFIG_VERSION}"
installer "com.electronwill.night-config:toml:${NIGHTCONFIG_VERSION}"
installer 'net.jodah:typetools:0.6.3'
installer "net.minecrell:terminalconsoleappender:${TERMINALCONSOLEAPPENDER_VERSION}"
installer "org.jline:jline-reader:${JLINE_VERSION}" // Dep of TerminalConsoleAppender
installer "org.jline:jline-terminal:${JLINE_VERSION}" // Dep of TerminalConsoleAppender
installer "org.jline:jline-terminal-jansi:${JLINE_VERSION}" // Dep of TerminalConsoleAppender
installer "org.spongepowered:mixin:${MIXIN_VERSION}"
installer 'org.openjdk.nashorn:nashorn-core:15.3'
installer "net.minecraftforge:JarJarSelector:${JARJAR_VERSION}"
installer "net.minecraftforge:JarJarMetadata:${JARJAR_VERSION}"
// LibraryLoader start
installer "org.apache.maven:maven-artifact:3.8.5"
installer 'org.apache.maven:maven-builder-support:3.8.5'
installer 'org.apache.maven:maven-model:3.8.5'
installer 'org.apache.maven:maven-model-builder:3.8.5'
installer 'org.apache.maven:maven-repository-metadata:3.8.5'
installer 'org.apache.maven:maven-resolver-provider:3.8.5'
installer 'org.apache.maven.resolver:maven-resolver-api:1.7.3'
installer 'org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3'
installer 'org.apache.maven.resolver:maven-resolver-impl:1.7.3'
installer 'org.apache.maven.resolver:maven-resolver-spi:1.7.3'
installer 'org.apache.maven.resolver:maven-resolver-transport-http:1.7.3'
installer 'org.apache.maven.resolver:maven-resolver-util:1.7.3'
installer 'org.eclipse.sisu:org.eclipse.sisu.inject:0.3.5'
installer 'org.codehaus.plexus:plexus-interpolation:1.25'
installer 'org.codehaus.plexus:plexus-utils:3.2.1'
// LibraryLoader end
installer 'org.joml:joml:1.10.5' // 1.19.4
compileOnly 'org.jetbrains:annotations:24.0.1'
// craftbukkit
installer 'org.fusesource.jansi:jansi:2.4.1'
installer 'jline:jline:2.14.6'
installer 'com.googlecode.json-simple:json-simple:1.1.1'
installer 'org.xerial:sqlite-jdbc:3.42.0.0'
installer 'com.mysql:mysql-connector-j:8.0.33'
installer 'net.md-5:SpecialSource:1.11.2'
// spigot
installer 'net.md-5:bungeecord-chat:1.20-R0.1' // #14
installer 'commons-codec:commons-codec:1.16.0'
installer 'commons-logging:commons-logging:1.2'
installer 'org.apache.httpcomponents:httpclient:4.5.13'
installer 'org.apache.httpcomponents:httpcore:4.4.14'
installer 'io.izzel:tools:1.3.0'
installer 'com.mohistmc:dynamicenum:0.3'
installer 'com.mohistmc:i18n:0.6'
installer 'com.mohistmc:brigadier:1.20.1'
installer 'com.mohistmc:librariesvault:1.20.1'
installer 'com.mohistmc:json:0.5'
installer 'com.mohistmc:tools:0.5.1'
installer "com.mohistmc:eventbus:${EVENTBUS_VERSION}"
installer 'com.ibm.icu:icu4j:71.1' // Forge 1.20.1
compileOnly 'me.clip:placeholderapi:2.11.5'
installer 'com.google.guava:failureaccess:1.0.1'
installer "com.google.guava:guava:${GUAVA_VERSION}"
installer 'com.google.code.gson:gson:2.10'
installer 'com.mojang:authlib:4.0.43'
installer 'com.mojang:logging:1.1.1'
installer 'commons-lang:commons-lang:2.6-mohist'
installer 'org.slf4j:slf4j-api:2.0.6'
installer 'org.apache.logging.log4j:log4j-core:2.20.0'
installer 'org.apache.logging.log4j:log4j-iostreams:2.20.0'
installer 'org.apache.logging.log4j:log4j-api:2.20.0'
installer 'org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0'
installer 'org.apache.commons:commons-lang3:3.12.0'
installer 'net.sf.jopt-simple:jopt-simple:5.0.4'
installer 'net.java.dev.jna:jna-platform:5.13.0'
installer 'net.java.dev.jna:jna:5.13.0'
installer 'it.unimi.dsi:fastutil:8.5.12'
installer 'commons-io:commons-io:2.11.0'
installer 'com.mojang:javabridge:2.0.25'
installer 'com.mojang:datafixerupper:6.0.8'
installer 'com.github.oshi:oshi-core:6.4.0'
installer 'io.netty:netty-buffer:4.1.82.Final'
installer 'io.netty:netty-codec:4.1.82.Final'
installer 'io.netty:netty-common:4.1.82.Final'
installer 'io.netty:netty-handler:4.1.82.Final'
installer 'io.netty:netty-resolver:4.1.82.Final'
installer 'io.netty:netty-transport:4.1.82.Final'
installer 'io.netty:netty-transport-classes-epoll:4.1.82.Final'
installer 'io.netty:netty-transport-native-unix-common:4.1.82.Final'
// Paper start
installer "net.kyori:adventure-api:${ADVENTURE_VERSION}"
installer "net.kyori:adventure-key:${ADVENTURE_VERSION}"
installer "net.kyori:adventure-text-minimessage:${ADVENTURE_VERSION}"
installer "net.kyori:adventure-text-serializer-gson:${ADVENTURE_VERSION}"
installer "net.kyori:adventure-text-serializer-json:${ADVENTURE_VERSION}"
installer "net.kyori:adventure-text-serializer-legacy:${ADVENTURE_VERSION}"
installer "net.kyori:adventure-text-serializer-plain:${ADVENTURE_VERSION}"
installer "net.kyori:adventure-text-serializer-ansi:${ADVENTURE_VERSION}"
installer "net.kyori:adventure-text-logger-slf4j:${ADVENTURE_VERSION}"
installer "net.kyori:ansi:1.0.3"
installer "net.kyori:examination-api:1.3.0"
installer "net.kyori:examination-string:1.3.0"
// Paper end
}
def sharedFmlonlyForge = { Project prj ->
['Client', 'Server', 'Joined'].each { side ->
['slim', 'extra'].each { type ->
prj.task([type: DownloadMavenArtifact], "download${side}${type.capitalize()}") {
artifact = "net.minecraft:${side.toLowerCase()}:${MC_VERSION}-${MCP_VERSION}:${type}"
}
}
if (side.equals('Joined')) {
prj.task([type: DownloadMavenArtifact], "createJoinedSRG") {
artifact = "net.minecraft:joined:${MC_VERSION}-${MCP_VERSION}:srg"
}
} else {
prj.task([type: RenameJar, dependsOn: prj.tasks.createMcp2Srg], "create${side}SRG") {
tool = FART
args = [
'--input', '{input}',
'--output', '{output}',
'--names', '{mappings}',
'--ann-fix', '--ids-fix', '--src-fix', '--record-fix'
]
mappings = prj.tasks.createMcp2Srg.srg
input = prj.tasks.getByName("download${side}Slim").output
output = prj.file("build/create${side}SRG/output.jar")
}
}
def gen = prj.tasks.getByName("gen${side}BinPatches")
def createSRG = prj.tasks.getByName("create${side}SRG")
gen.dependsOn(createSRG)
gen.tool = BINPATCH_TOOL
gen.cleanJar = createSRG.output
prj.task([type: ApplyBinPatches, dependsOn: gen], "apply${side}BinPatches") {
clean = gen.cleanJar
patch = gen.output
tool = BINPATCH_TOOL
}
}
prj.task([type: DownloadMavenArtifact], 'downloadInstaller') {
artifact = "net.minecraftforge:installer:${INSTALLER_VERSION}:fatjar"
changing = true
}
eclipse.project.resourceFilter {
appliesTo = 'FOLDERS'
type = 'EXCLUDE_ALL'
matcher {
id = 'org.eclipse.ui.ide.multiFilter'
arguments = '1.0-name-matches-false-false-run'
}
}
def MODULE_PATH = getArtifacts(prj, prj.configurations.moduleonly, false).values().collect{"libraries/${it.downloads.artifact.path}"}
def tokens = [
TASK: 'forgeserver',
MAVEN_PATH: prj.ext.MAVEN_PATH.toString(),
FORGE_VERSION: FORGE_VERSION,
MC_VERSION: MC_VERSION,
MCP_VERSION: MCP_VERSION,
FORGE_GROUP: prj.group,
IGNORE_LIST: getArtifacts(prj, prj.configurations.moduleonly, false).values().collect{it.downloads.artifact.path.rsplit('/', 1)[1]}.join(','),
MODULES: 'ALL-MODULE-PATH'
]
prj.task('makeClasspathFiles') {
doLast {
def CLASS_PATH = getArtifacts(prj, prj.configurations.installer, false).values().collect{"libraries/${it.downloads.artifact.path}"} +
[
'libraries/' + getMavenPath(rootProject.tasks.findByPath(':fmlloader:jar')),
"libraries/net/minecraft/server/${MC_VERSION}-${MCP_VERSION}/server-${MC_VERSION}-${MCP_VERSION}-extra.jar"
]
configure(prj.installerJar) {
from(rootProject.file('server_files/args.txt')) {
filter(ReplaceTokens, tokens: tokens + [MODULE_PATH: MODULE_PATH.join(';'), CLASS_PATH: CLASS_PATH.join(';')])
rename { 'data/win_args.txt' }
}
from(rootProject.file('server_files/args.txt')) {
filter(ReplaceTokens, tokens: tokens + [MODULE_PATH: MODULE_PATH.join(':'), CLASS_PATH: CLASS_PATH.join(':')])
rename { 'data/unix_args.txt' }
}
}
}
}
}
project(':mohist') {
evaluationDependsOn(':clean')
apply plugin: 'java-library'
apply plugin: 'net.minecraftforge.gradle.patcher'
applyPatches { level 'WARNING' }
sourceSets {
main {
java {
srcDirs = [
"$rootDir/src/main/java",
"$rootDir/src/fmlcommon/java",
SNAPSHOT ? "$rootDir/src/snapshots/java" : "$rootDir/src/snapshots_disabled/java"
]
}
resources {
srcDirs = [
"$rootDir/src/main/resources",
"$rootDir/src/generated/resources",
"$rootDir/src/fmlcommon/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/') } }
ext {
SPEC_VERSION = gradleutils.gitInfo.tag
// 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.get()
VERSION_JSON = project(':mcp').file('build/mcp/downloadJson/version.json')
PACKED_DEPS = [':fmlcore:jar', ':fmlloader:jar', ':javafmllanguage:jar', ':lowcodelanguage:jar', ':mclanguage:jar']
MAVEN_PATH = "${group.replace('.', '/')}/${project.name}/${VERSION}"
}
configurations {
installer {
// Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it.
transitive = false
}
mohist {
// Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it.
transitive = false
}
moduleonly
api.extendsFrom(installer)
}
task downloadJars(type: Copy) {
from configurations.installer
into 'libraries'
}
task downloadMultipleFiles(type: Download) {
src([
'https://maven.mohistmc.com/libraries/1.20.1/mohist/libraries.zip'
])
dest layout.buildDirectory.dir("libraries")
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testImplementation 'org.junit.vintage:junit-vintage-engine:5.+'
testImplementation 'org.opentest4j:opentest4j:1.2.0' // needed for junit 5
testImplementation 'org.hamcrest:hamcrest-all:1.3' // needs advanced matching for list order
implementation project(':fmlcore')
implementation project(':fmlloader')
implementation project(':javafmllanguage')
implementation project(':lowcodelanguage')
implementation project(':mclanguage')
runtimeOnly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}"
}
dependencies sharedDeps
dependencies mohistDeps
patcher {
excs.from file("$rootDir/src/main/resources/forge.exc")
parent = project(':clean')
patches = file("$rootDir/patches/minecraft")
patchedSrc = file('src/main/java')
srgPatches = true
accessTransformers.from file("$rootDir/src/main/resources/META-INF/accesstransformer.cfg")
sideAnnotationStrippers.from file("$rootDir/src/main/resources/forge.sas")
runs {
forge_server {
args '--launchTarget', 'forgeserverdev'
ideaModule "${rootProject.name}.${project.name}.main"
mods {
minecraft { source sourceSets.main }
}
}
def forgeDataArgs = [
'--mod', 'forge',
'--all',
'--output', rootProject.file('src/generated/resources/'),
'--validate',
'--existing', sourceSets.main.resources.srcDirs[0]
]
forge_data {
taskName 'forge_data'
args '--launchTarget', 'forgedatadev'
ideaModule "${rootProject.name}.${project.name}.main"
mods {
minecraft { source sourceSets.main }
}
args forgeDataArgs
}
}
}
ext {
MANIFESTS = [
'/': [
'Timestamp' : new SimpleDateFormat("yyyy.MM.dd.HHmm").format(new Date()),
'GitCommit' : gradleutils.gitInfo.abbreviatedId,
'Git-Branch' : '1.20.1',
'FML-System-Mods': 'forge'
] 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,
'com/mohistmc/' : [
'Specification-Title' : 'Mohist',
'Specification-Vendor' : 'MohistMC',
'Specification-Version' : MOHIST_VERSION,
'Implementation-Title' : 'Mohist',
'Implementation-Version': '1.20.1-' + MOHIST_VERSION,
'Implementation-Vendor' : 'MohistMC'
] as LinkedHashMap,
'org/bukkit/craftbukkit/v1_20_R1/' : [
'Specification-Title' : MCP_VERSION,
'Specification-Vendor' : 'SpigotMC',
'Specification-Version' : '1.20.1',
'Implementation-Title' : 'Spigot',
'Implementation-Version': bukkit_version + '-' + craftbukkit_version + '-' + spigot_version + '-' + neoforge_version,
'Implementation-Vendor' : 'SpigotMC'
] as LinkedHashMap
]
}
sharedFmlonlyForge.call(project)
task downloadLibraries(type: DownloadLibraries, dependsOn: ':mcp:setupMCP') {
input = VERSION_JSON
output = rootProject.file('build/libraries/')
}
task extractInheritance(type: ExtractInheritance, dependsOn: [downloadLibraries]) {
tool = INSTALLER_TOOLS + ':fatjar'
args.add '--annotations'
input = genJoinedBinPatches.cleanJar
libraries.addAll downloadLibraries.librariesOutput.map { rf -> Files.readAllLines(rf.asFile.toPath()).stream().map(File::new).collect(Collectors.toList()) }
}
task findFieldInstanceChecks(type: FieldCompareFinder, dependsOn: ['createJoinedSRG']) {
jar = createJoinedSRG.output
output = rootProject.file('src/main/resources/coremods/field_to_instanceof.json')
fields {
}
}
task findFinalizeSpawnTargets(type: BytecodePredicateFinder, dependsOn: ['createJoinedSRG']) {
jar = createJoinedSRG.output
output = rootProject.file('src/main/resources/coremods/finalize_spawn_targets.json')
predicate = {
parent, node, insn ->
'net/minecraft/world/level/BaseSpawner' != parent.name // Ignore this class as we special case it.
&& insn.getOpcode() == Opcodes.INVOKEVIRTUAL
&& insn.name.equals('m_6518_')
&& insn.desc.equals('(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/world/entity/SpawnGroupData;')
}
}
tasks.register('validateDeprecations', ValidateDeprecations) {
input = tasks.jar.archiveFile
mcVersion = MC_VERSION
}
tasks.jar.finalizedBy 'validateDeprecations'
tasks.register('checkAll') {
dependsOn 'checkLicenses'
group = 'checks'
}
tasks.register('checkAllAndFix') {
dependsOn 'findFieldInstanceChecks', 'checkLicenses'
group = 'checks'
}
CheckTask.registerTask(tasks, 'ATs', CheckATs) {
dependsOn extractInheritance, createSrg2Mcp
ats.from patcher.accessTransformers
inheritance = extractInheritance.output
mappings = createSrg2Mcp.output
}
CheckTask.registerTask(tasks, 'SAS', CheckSAS) {
dependsOn extractInheritance
sass.from patcher.sideAnnotationStrippers
inheritance = extractInheritance.output
}
CheckTask.registerTask(tasks, 'Excs', CheckExcs) {
dependsOn jar
binary = jar.archiveFile.get().asFile
excs.from patcher.excs
}
CheckTask.registerTask(tasks, 'Patches', CheckPatches) {
dependsOn genPatches
patchDir = file("$rootDir/patches")
patchesWithS2SArtifact = [
'minecraft/net/minecraft/client/renderer/ViewArea.java.patch',
'minecraft/net/minecraft/data/models/blockstates/Variant.java.patch',
]
}
tasks.register('fixPatchImports', FixPatchImports) {
clean.set(rootProject.file('projects/clean/src/main/java'))
patched.set(rootProject.file('projects/forge/src/main/java'))
}
genPatches {
autoHeader true
lineEnding = '\n'
}
def baseForgeVersionProperty = project.objects.property(String)
baseForgeVersionProperty.set(project.provider { getLatestForgeVersion(MC_VERSION) }.map { MC_VERSION + '-' + it })
baseForgeVersionProperty.finalizeValueOnRead()
def jarCompatibilityTaskSetup = { task ->
task.group = 'jar compatibility'
task.onlyIf {
baseForgeVersionProperty.getOrNull() != null
}
}
tasks.register('setupCheckJarCompatibility', SetupCheckJarCompatibility) {
inputVersion = baseForgeVersionProperty
}
tasks.register('applyBaseCompatibilityJarBinPatches', ApplyBinPatches) {
jarCompatibilityTaskSetup(it)
clean = project.tasks.createJoinedSRG.output
patch = project.tasks.named('setupCheckJarCompatibility').flatMap { it.baseBinPatchesOutput }
output = project.layout.buildDirectory.dir(name).map { it.file('output.jar') }
}
tasks.register('checkJarCompatibility', CheckJarCompatibility) {
jarCompatibilityTaskSetup(it)
dependsOn 'setupCheckJarCompatibility'
baseJar = project.tasks.named('mergeBaseForgeJar').flatMap { it.output }
baseLibraries.from(project.tasks.named('createJoinedSRG').flatMap { it.output })
inputJar = project.tasks.named('reobfJar').flatMap { it.output }
concreteLibraries.from(project.PACKED_DEPS.collect { project.rootProject.tasks.getByPath(it).archiveFile })
commonLibraries.from(project.configurations.minecraftImplementation)
commonLibraries.from(project.configurations.installer)
commonLibraries.from(project.configurations.moduleonly)
}
universalJar {
duplicatesStrategy = 'exclude'
doFirst {
MANIFESTS.each{ pkg, values ->
if (pkg == '/') {
manifest.attributes(values)
} else {
manifest.attributes(values, pkg)
}
}
}
}
task packageLibraries(type: Zip, dependsOn: [downloadMultipleFiles]) {
archiveFileName = 'libraries.zip'
destinationDirectory = file("build/distributions")
outputs.upToDateWhen {
false // TODO: Not 100% sure how to make this task re-run when libraries are changed...
}
configurations.mohist.resolvedConfiguration.resolvedArtifacts.collect {
def moduleVersion = it.moduleVersion
from (it.file) {
into ("${moduleVersion.id.group.replace('.', '/')}/${moduleVersion.id.name}/${moduleVersion.id.version}/")
}
}
configurations.installer.resolvedConfiguration.resolvedArtifacts.collect {
def moduleVersion = it.moduleVersion
from (it.file) {
into ("${moduleVersion.id.group.replace('.', '/')}/${moduleVersion.id.name}/${moduleVersion.id.version}/")
}
}
}
task mohistJar(type: Jar, dependsOn: [packageLibraries, genServerBinPatches, project(':mohistlauncher').tasks.jar]) {
archiveClassifier = 'server'
archiveExtension = 'jar'
archiveBaseName = 'mohist-rpg'
archiveVersion = '1.20.1-' + MOHIST_VERSION
destinationDirectory = file('build/libs')
def CLASS_PATH = getArtifacts(project, project.configurations.installer, false).values().collect { "libraries/${it.downloads.artifact.path}" } +
[
'libraries/' + getMavenPath(rootProject.tasks.findByPath(':fmlloader:jar')),
"libraries/net/minecraft/server/${MC_VERSION}-${MCP_VERSION}/server-${MC_VERSION}-${MCP_VERSION}-extra.jar",
"libraries/cpw/mods/bootstraplauncher/1.1.2/bootstraplauncher-1.1.2.jar",
"libraries/cpw/mods/securejarhandler/mohist-2.1.11/securejarhandler-mohist-2.1.11.jar",
"libraries/net/minecraftforge/installertools/1.4.1/installertools-1.4.1.jar",
"libraries/io/netty/netty-transport-native-epoll/4.1.82.Final/netty-transport-native-epoll-4.1.82.Final-linux-x86_64.jar",
"libraries/io/netty/netty-transport-native-epoll/4.1.82.Final/netty-transport-native-epoll-4.1.82.Final-linux-aarch_64.jar"
]
def MODULE_PATH = getArtifacts(project, project.configurations.moduleonly, false).values().collect { "libraries/${it.downloads.artifact.path}" }
def tokens = [
TASK : 'forgeserver',
MAVEN_PATH : project.ext.MAVEN_PATH.toString(),
FORGE_VERSION: FORGE_VERSION,
MC_VERSION : MC_VERSION,
MCP_VERSION : MCP_VERSION,
FORGE_GROUP : project.group,
IGNORE_LIST : getArtifacts(project, project.configurations.moduleonly, false).values().collect { it.downloads.artifact.path.rsplit('/', 1)[1] }.join(',').replace("2.1.2", "mohist-2.1.11"),
MODULES : 'ALL-MODULE-PATH'
]
doFirst {
MANIFESTS.each { pkg, values ->
if (pkg == '/') {
manifest.attributes(values += [
'Premain-Class': 'com.mohistmc.util.JarLoader',
'Launcher-Agent-Class': 'com.mohistmc.util.JarLoader',
'Main-Class': 'com.mohistmc.MohistMCStart',
'Class-Path': CLASS_PATH.toString().replace("[", "").replace("]", "").replace(",", "")
])
} else {
manifest.attributes(values, pkg)
}
}
}
//println(CLASS_PATH)
from(genServerBinPatches.output) {
rename { 'data/server.lzma' }
}
from(universalJar) {
rename { 'data/forge-' + MC_VERSION + '-' + FORGE_VERSION + '-universal.jar' }
}
from(project(':fmlloader').tasks.jar.outputs) {
rename { 'data/fmlloader-' + MC_VERSION + '-' + FORGE_VERSION + '.jar' }
}
from(project(':fmlcore').tasks.jar.outputs) {
rename { 'data/fmlcore-' + MC_VERSION + '-' + FORGE_VERSION + '.jar' }
}
from(project(':javafmllanguage').tasks.jar.outputs) {
rename { 'data/javafmllanguage-' + MC_VERSION + '-' + FORGE_VERSION + '.jar' }
}
from(project(':mclanguage').tasks.jar.outputs) {
rename { 'data/mclanguage-' + MC_VERSION + '-' + FORGE_VERSION + '.jar' }
}
from(project(':lowcodelanguage').tasks.jar.outputs) {
rename { 'data/lowcodelanguage-' + MC_VERSION + '-' + FORGE_VERSION + '.jar' }
}
from(project(':mohistplugins').tasks.jar.outputs) {
rename { 'data/mohistplugins-' + MC_VERSION + '.jar' }
}
from(zipTree(project(':mohistlauncher').tasks.jar.outputs.getFiles().asPath.replace(".jar", "-all.jar"))) {
into ""
}
from(zipTree(packageLibraries.outputs.getFiles().asPath)) {
into 'META-INF/libraries'
}
from(zipTree(downloadMultipleFiles.outputs.getFiles().asPath)) {
into 'META-INF/libraries'
}
from(rootProject.file('server_files/version.txt')) {
filter(ReplaceTokens, tokens: [VERSION: MOHIST_VERSION])
rename { 'versions/mohist.txt' }
}
from(rootProject.file('server_files/version.txt')) {
filter(ReplaceTokens, tokens: [VERSION: MC_VERSION])
rename { 'versions/minecraft.txt' }
}
from(rootProject.file('server_files/version.txt')) {
filter(ReplaceTokens, tokens: [VERSION: FORGE_VERSION])
rename { 'versions/forge.txt' }
}
from(rootProject.file('server_files/version.txt')) {
filter(ReplaceTokens, tokens: [VERSION: MCP_VERSION])
rename { 'versions/mcp.txt' }
}
from(rootProject.file('server_files/args.txt')) {
filter(ReplaceTokens, tokens: tokens + [MODULE_PATH: MODULE_PATH.join(';').replace("2.1.2", "mohist-2.1.11"), CLASS_PATH: CLASS_PATH.join(';').replace("2.1.2", "mohist-2.1.11")]) // modlauncher use 2.1.2
rename { 'data/win_args.txt' }
}
from(rootProject.file('server_files/args.txt')) {
filter(ReplaceTokens, tokens: tokens + [MODULE_PATH: MODULE_PATH.join(':').replace("2.1.2", "mohist-2.1.11"), CLASS_PATH: CLASS_PATH.join(':').replace("2.1.2", "mohist-2.1.11")]) // modlauncher use 2.1.2
rename { 'data/unix_args.txt' }
}
}
tasks.register('genAllData') {
dependsOn 'forge_data'
}
tasks.eclipse.dependsOn('genEclipseRuns')
// Since we need the modules in the bootstrap, we need to make sure they are compiled before we do each run
afterEvaluate { prepareRuns.dependsOn(PACKED_DEPS) }
}
//evaluationDependsOnChildren()
task setup() { //These must be strings so that we can do lazy resolution. Else we need evaluationDependsOnChildren above
dependsOn ':clean:extractMapped'
dependsOn ':mohist:extractMapped'
}
project.gradle.startParameter.excludedTaskNames.add(':clean:genPatches')