Files
Tenet/build_mohist.gradle
2024-10-19 22:47:36 +08:00

805 lines
29 KiB
Groovy

import net.minecraftforge.forge.tasks.checks.CheckATs
import net.minecraftforge.forge.tasks.checks.CheckExcs
import net.minecraftforge.forge.tasks.checks.CheckPatches
import net.minecraftforge.forge.tasks.checks.CheckSAS
import net.minecraftforge.forge.tasks.checks.CheckTask
import org.apache.tools.ant.filters.ReplaceTokens
import net.minecraftforge.forge.tasks.*
import static net.minecraftforge.forge.tasks.Util.*
import net.minecraftforge.gradle.common.tasks.ApplyBinPatches
import net.minecraftforge.gradle.common.tasks.CheckJarCompatibility
import net.minecraftforge.gradle.common.tasks.DownloadMavenArtifact
import net.minecraftforge.gradle.common.tasks.ExtractInheritance
import net.minecraftforge.gradle.patcher.tasks.FilterNewJar
import net.minecraftforge.gradle.patcher.tasks.GeneratePatches
import net.minecraftforge.gradle.userdev.tasks.RenameJar
import org.objectweb.asm.Opcodes
plugins {
id 'idea'
id 'eclipse'
id 'java-library'
id 'de.undercouch.download'
id 'net.minecraftforge.gradleutils'
id 'net.minecraftforge.gradle.patcher'
id 'net.minecraftforge.gradlejarsigner'
}
Util.init() //Init all our extension methods!
// We depend on all other projects so that we can know their versions for userdev config
rootProject.subprojects.each { sib -> if (sib != project) evaluationDependsOn(sib.path) }
apply from: rootProject.file('build_shared.gradle')
java {
toolchain.languageVersion = JavaLanguageVersion.of(JAVA_VERSION)
withSourcesJar()
}
jarSigner.autoDetect('forge')
applyPatches {
level 'WARNING'
failOnError = UPDATING != 'true'
}
sourceSets {
main {
java {
srcDir "$rootDir/src/main/java"
}
resources {
srcDir "$rootDir/src/main/resources"
srcDir "$rootDir/src/main/generated"
}
}
}
final String 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.
final def MCP_ARTIFACT = project(':mcp').mcp.config.get()
final List<File> EXTRA_TXTS = [
rootProject.file('LICENCE/LICENSE-FORGE.txt')
]
ext {
MAVEN_PATH = "${group.toString().replace('.', '/')}/${project.name}/${VERSION}".toString()
}
final String MAVEN_PATH = ext.MAVEN_PATH
final String BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.2.0:fatjar'
final String INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.4.3'
final String FART = 'net.minecraftforge:ForgeAutoRenamingTool:1.0.6'
final String S2S_TOOL = 'net.minecraftforge:Srg2Source:8.1.0:fatjar'
configurations {
// Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it.
bootstrap { transitive = false }
installer {
extendsFrom(bootstrap)
transitive = false
}
installerextra {
extendsFrom(bootstrap)
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
}
api.extendsFrom(installer)
}
dependencies {
// These need to actually be on the classpath at the start. This is only used for the server shim jar.
// And this is only needed because custom file systems are REQUIRED to be on the boot classloader.
// This has ASM/BootStrap/Unsafe all because I haven't gotten around to moving UnionFileSystem out to its own project.
bootstrap(libs.jarjar.fs) // JarInJar file system
bootstrap(libs.bundles.jimfs) // In memory file system used for ForgeDev launches
bootstrap(libs.securemodules) // Has Union file system in it
bootstrap(libs.unsafe) // Needed by securemodules
bootstrap(libs.bundles.asm) // Needed by securemodules
implementation(libs.jopt.simple) { version { strictly '5.0.4' } }
installer(libs.bootstrap)
installer(libs.bootstrap.api) // Needed by securemodules
installer(libs.accesstransformers)
installer(libs.eventbus)
installer(libs.typetools) // Dep of EventBus
installer(libs.forgespi)
installer(libs.coremods)
installer(libs.nashorn) // Dep of Coremods
installer(libs.modlauncher)
installer(libs.mergetool.api)
installer(libs.bundles.night.config)
installer(libs.maven.artifact)
installer(libs.bundles.terminalconsoleappender)
installer(libs.mixin)
installer(libs.bundles.jarjar)
installer(project(':fmlcore'))
installer(project(':fmlloader'))
installer(project(':javafmllanguage'))
installer(project(':lowcodelanguage'))
installer(project(':mclanguage'))
installerextra("${MCP_ARTIFACT.group}:${MCP_ARTIFACT.name}:${MCP_ARTIFACT.version}:srg2off")
runtimeOnly(libs.bootstrap)
runtimeOnly(libs.bootstrap.dev)
// craftbukkit
installer 'org.fusesource.jansi:jansi:2.4.1'
implementation 'jline:jline:2.14.6'
installer 'com.googlecode.json-simple:json-simple:1.1.1'
installer 'org.xerial:sqlite-jdbc:3.46.0.0'
installer 'com.mysql:mysql-connector-j:8.4.0'
installer 'net.md-5:SpecialSource:1.11.2'
// spigot
installer 'net.md-5:bungeecord-chat:1.20-R0.2' // #65
installer 'commons-codec:commons-codec:1.16.0'
installer 'net.sf.jopt-simple:jopt-simple:5.0.4'
installer 'io.izzel:tools:1.3.0'
installer(libs.dynamicenum)
installer(libs.i18n)
installer(libs.json)
installer(libs.tools)
installer('net.minecraftforge:installertools:1.4.3')
installer 'com.mohistmc:librariesvault:1.20.2'
compileOnly 'me.clip:placeholderapi:2.11.6'
installer 'commons-lang:commons-lang:2.6-mohist'
// Paper start
installer(libs.bundles.log4j)
installer(libs.bundles.adventure)
// Paper end
installer 'io.netty:netty-buffer:4.1.97.Final'
installer 'io.netty:netty-codec:4.1.97.Final'
installer 'io.netty:netty-common:4.1.97.Final'
installer 'io.netty:netty-handler:4.1.97.Final'
installer 'io.netty:netty-resolver:4.1.97.Final'
installer 'io.netty:netty-transport:4.1.97.Final'
installer 'io.netty:netty-transport-classes-epoll:4.1.97.Final'
installer 'io.netty:netty-transport-native-unix-common:4.1.97.Final'
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'
installer 'org.joml:joml:1.10.5'
installer 'org.apache.commons:commons-lang3:3.14.0'
installer 'net.java.dev.jna:jna-platform:5.14.0'
installer 'net.java.dev.jna:jna:5.14.0'
installer 'org.slf4j:slf4j-api:2.0.9'
installer 'com.mojang:authlib:6.0.54'
installer 'com.mojang:logging:1.2.7'
installer 'com.mojang:brigadier:1.3.10'
installer 'com.mojang:datafixerupper:8.0.16'
installer 'com.google.code.gson:gson:2.10.1'
installer 'com.google.guava:failureaccess:1.0.1'
installer 'commons-logging:commons-logging:1.2'
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.2.2"
mohist "net.minecraftforge:installertools:1.4.1"
mohist 'net.minecraftforge:binarypatcher:1.2.0'
mohist "net.minecraftforge:ForgeAutoRenamingTool:1.0.6:all"
mohist "net.minecraftforge:srgutils:0.5.6"
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 "com.google.code.findbugs:jsr305:3.0.2"
mohist 'org.checkerframework:checker-qual:2.0.0'
mohist 'commons-io:commons-io:2.15.1'
mohist 'it.unimi.dsi:fastutil:8.5.12'
mohist 'com.google.jimfs:jimfs:1.3.0'
}
tasks.named('extractRangeMap').configure {
tool = S2S_TOOL
}
patcher {
excs.from file("$rootDir/src/main/resources/forge.exc")
parent = project(':mcp')
mcVersion = MC_VERSION
mappings channel: MAPPING_CHANNEL, version: MAPPING_VERSION
patches = file("$rootDir/patches/minecraft")
patchedSrc = file('src/main/java')
srgPatches = false
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', 'forge_dev_server'
}
forge_data {
args '--launchTarget', 'forge_dev_data',
'--mod', 'forge',
'--all',
'--validate',
'--output', rootProject.file('src/main/generated/'),
'--validate',
'--existing', sourceSets.main.resources.srcDirs[0],
'--assetsDir', downloadAssets.output,
'--assetIndex', "{asset_index}"
}
}
}
afterEvaluate {
if (!patcher.srgPatches) {
srg2mcpClean {
dependsOn = []
input = project(':mcp').setupMCP.output
}
userdevJar {
onlyIf = { t -> true }
}
def patches = project.file('build/genPatchesForUserdev/output/')
patches.mkdirs()
def genPatchesForUserdev = tasks.register('genPatchesForUserdev', GeneratePatches){
base = project(':mcp').setupMCP.output
modified = applyRangeMapBase.output
originalPrefix = genPatches.originalPrefix
modifiedPrefix = genPatches.modifiedPrefix
output = patches
autoHeader true
lineEnding = '\n'
}
bakePatches {
dependsOn = []
input = genPatchesForUserdev.get().output
}
}
}
tasks.register('downloadCrowdin', Download) {
src 'https://files.minecraftforge.net/crowdin.zip'
dest file('build/crowdin.zip')
useETag 'all'
onlyIfModified true
quiet true
}
tasks.userdevConfig.configure {
configurations.installer.allDependencies.forEach {
def dep = it.toString()
if (it instanceof ProjectDependency)
dep = "net.minecraftforge:$it.dependencyProject.name:$it.dependencyProject.version"
libraries.add(dep)
}
inject = '' // We don't have a userdev sourceset anymore. Empty as a gradle workaround...
runs {
client {
environment 'MCP_MAPPINGS', '{mcp_mappings}'
property 'forge.enableGameTest', 'true'
args '--launchTarget', "forge_userdev_client"
args '--version', 'MOD_DEV'
args '--assetIndex', '{asset_index}'
args '--assetsDir', '{assets_root}'
}
server {
environment 'MCP_MAPPINGS', '{mcp_mappings}'
property 'forge.enableGameTest', 'true'
args '--launchTarget', "forge_userdev_server"
}
gameTestServer {
environment 'MCP_MAPPINGS', '{mcp_mappings}'
args '--launchTarget', "forge_userdev_server_gametest"
}
data {
environment 'MCP_MAPPINGS', '{mcp_mappings}'
args '--launchTarget', "forge_userdev_data"
args '--assetIndex', '{asset_index}'
args '--assetsDir', '{assets_root}'
}
}
}
for (def run : patcher.runs + tasks.userdevConfig.runs) {
if (run.parents) continue // We already added this to the parent run config
//run.property 'bsl.debug', 'true'
run.args '--gameDir', '.'
run.jvmArgs '-Djava.net.preferIPv6Addresses=system'
run.client run.name.contains('client')
run.main 'net.minecraftforge.bootstrap.ForgeBootstrap'
}
for (def run : patcher.runs) {
run.taskName = run.name
run.workingDirectory file('run/' + run.name)
run.ideaModule rootProject.name + '.' + project.name + '.main'
run.property 'bsl.debug', 'true'
run.property 'terminal.jline', 'true'
}
tasks.register('downloadVersionManifest', Download) {
src 'https://piston-meta.mojang.com/mc/game/version_manifest_v2.json'
dest file('build/versions/version_manifest.json')
useETag 'all'
onlyIfModified true
quiet true
}
tasks.register('downloadJson', Download) {
dependsOn downloadVersionManifest
inputs.file downloadVersionManifest.dest
src { downloadVersionManifest.dest.json.versions.find{ it.id == MC_VERSION }.url }
dest file("build/versions/$MC_VERSION/version.json")
useETag 'all'
onlyIfModified true
quiet true
}
tasks.register('downloadClientRaw', Download) {
dependsOn downloadJson
inputs.file downloadJson.dest
src { downloadJson.dest.json.downloads.client.url }
dest file("build/versions/$MC_VERSION/client.jar")
useETag 'all'
onlyIfModified true
quiet true
}
tasks.register('downloadServerRaw', Download) {
dependsOn downloadJson
inputs.file downloadJson.dest
src { downloadJson.dest.json.downloads.server.url }
dest file("build/versions/$MC_VERSION/server-bundled.jar")
useETag 'all'
onlyIfModified true
quiet true
}
tasks.register('extractServer', ExtractFile) {
dependsOn downloadServerRaw
input = downloadServerRaw.dest
target = "META-INF/versions/$MC_VERSION/server-${MC_VERSION}.jar"
output = file("build/versions/$MC_VERSION/server.jar")
}
tasks.register('downloadLibraries', DownloadLibraries) {
dependsOn downloadJson
input = downloadJson.dest
output = rootProject.file('build/libraries/')
}
tasks.register('extractInheritance', ExtractInheritance) {
dependsOn downloadLibraries
tool = INSTALLER_TOOLS + ':fatjar'
args.add '--annotations'
input = genJoinedBinPatches.cleanJar
libraries.addAll downloadLibraries.librariesOutput.map { rf ->
java.nio.file.Files.readAllLines(rf.asFile.toPath()).stream().map(File::new).collect(java.util.stream.Collectors.toList())
}
}
tasks.register("findFinalizeSpawnTargets", BytecodePredicateFinder) {
jar = createJoinedSRG.output
output = rootProject.file('src/main/resources/coremods/finalize_spawn_targets.json')
predicate = {
parent, node, insn ->
return 'net/minecraft/world/level/BaseSpawner' != parent.name // Ignore this class as we special case it.
&& insn.getOpcode().equals(Opcodes.INVOKEVIRTUAL)
&& insn.name.equals('m_6518_')
&& insn.desc == '(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;';
}
}
tasks.register('validateDeprecations', ValidateDeprecations) {
input = tasks.jar.archiveFile
mcVersion = MC_VERSION
}
tasks.jar.finalizedBy 'validateDeprecations'
tasks.register("downloadInstaller", DownloadMavenArtifact) {
artifact = "net.minecraftforge:installer:2.2.+:fatjar"
changing = true
}
tasks.register("downloadServerShim", DownloadMavenArtifact) {
artifact = libs.bootstrap.shim.get().toString()
changing = true
}
tasks.register('downloadClientMappings', net.minecraftforge.gradle.common.tasks.JarExec) {
ext.output = file('build/client_mappings.tsrg')
tool = INSTALLER_TOOLS + ':fatjar'
args = ['--task', 'DOWNLOAD_MOJMAPS', '--sanitize', '--version', MC_VERSION, '--side', 'client', '--output', output.absolutePath]
outputs.file(output)
}
tasks.register('downloadServerMappings', net.minecraftforge.gradle.common.tasks.JarExec) {
ext.output = file('build/server_mappings.tsrg')
tool = INSTALLER_TOOLS + ':fatjar'
args = ['--task', 'DOWNLOAD_MOJMAPS', '--sanitize', '--version', MC_VERSION, '--side', 'server', '--output', output.absolutePath]
outputs.file(output)
}
tasks.register("createJoinedSRG", DownloadMavenArtifact) {
artifact = "net.minecraft:joined:${MC_VERSION}-${MCP_VERSION}:srg"
}
tasks.register("createClientOfficial", RenameJar) {
tool = FART + ':all'
args = ['--input', '{input}', '--output', '{output}', '--names', '{mappings}', '--ann-fix', '--ids-fix', '--src-fix', '--record-fix', '--strip-sigs', '--reverse']
mappings = downloadClientMappings.output
dependsOn(downloadClientRaw, downloadClientMappings)
input = downloadClientRaw.dest
output = file("build/createClientOfficial/output.jar")
}
tasks.register("createServerOfficial", RenameJar) {
tool = FART + ':all'
args = ['--input', '{input}', '--output', '{output}', '--names', '{mappings}', '--ann-fix', '--ids-fix', '--src-fix', '--record-fix', '--strip-sigs', '--reverse']
mappings = downloadServerMappings.output
dependsOn(downloadServerMappings)
input = extractServer.output
output = file("build/createServerOfficial/output.jar")
}
tasks.named('genClientBinPatches').configure {
tool = BINPATCH_TOOL
cleanJar = createClientOfficial.output
dirtyJar = jar.archiveFile
}
tasks.named('genServerBinPatches').configure {
tool = BINPATCH_TOOL
cleanJar = createServerOfficial.output
dirtyJar = jar.archiveFile
}
tasks.named('genJoinedBinPatches').configure {
tool = BINPATCH_TOOL
cleanJar = createJoinedSRG.output
}
tasks.register('applyClientBinPatches', ApplyBinPatches) {
tool = BINPATCH_TOOL
clean = createClientOfficial.output
patch = genClientBinPatches.output
args.addAll(['--data', '--unpatched'])
}
tasks.register('applyServerBinPatches', ApplyBinPatches) {
tool = BINPATCH_TOOL
clean = createServerOfficial.output
patch = genServerBinPatches.output
args.addAll(['--data', '--unpatched'])
}
tasks.register('applyJoinedBinPatches', ApplyBinPatches) {
tool = BINPATCH_TOOL
clean = genJoinedBinPatches.cleanJar
patch = genJoinedBinPatches.output
}
tasks.register('createServerShimClasspath', BundleList) {
dependsOn(downloadServerRaw)
serverBundle = downloadServerRaw.dest
}
tasks.register('createServerShimConfig') {
ext.output = file('build/libs/bootstrap-shim.properties')
doLast {
var cfg = new CleanProperties()
cfg['Main-Class'] = 'net.minecraftforge.bootstrap.ForgeBootstrap'
cfg['Java-Version'] = '21'
cfg['Arguments'] = '--launchTarget forge_server'
cfg.store(output)
}
}
tasks.register('serverShimJar', Jar) {
dependsOn(createServerShimConfig)
from (createServerShimConfig.output)
from (createServerShimClasspath.output) {
rename { 'bootstrap-shim.list' }
}
from (zipTree(downloadServerShim.output))
manifest {
from {
zipTree(downloadServerShim.output).find { it.name == 'MANIFEST.MF' }
}
attributes('Class-Path': configurations.bootstrap.resolvedConfiguration.resolvedArtifacts.collect { "libraries/${Util.getMavenInfoFromDep(it).path}" }.join(' '))
}
archiveClassifier = 'shim'
jarSigner.sign(it)
}
tasks.register('checkAll') {
group = 'checks'
}
tasks.register('checkAllAndFix') {
dependsOn 'findFinalizeSpawnTargets'
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',
]
}
genPatches {
// finalizedBy checkAndFixPatches
autoHeader true
lineEnding = '\n'
}
def baseForgeVersionProperty = project.objects.property(String)
baseForgeVersionProperty.set(project.provider { TeamcityRequests.attemptFindBase(rootDir) ?: getLatestForgeVersion(MC_VERSION) })
baseForgeVersionProperty.finalizeValueOnRead()
final jarCompatibilityTaskSetup = { Task 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('mergeBaseForgeJar', MergeJars) {
jarCompatibilityTaskSetup(it)
inputJars.from(project.tasks.named('applyBaseCompatibilityJarBinPatches').flatMap { it.output })
inputJars.from(baseForgeVersionProperty.map { inputVersion ->
def output = project.layout.buildDirectory.dir(name).map { it.file("forge-${inputVersion}-universal.jar") }.get().asFile
project.rootProject.extensions.download.run {
src "https://maven.minecraftforge.net/net/minecraftforge/forge/${inputVersion}/forge-${inputVersion}-universal.jar"
dest output
}
return output
})
}
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 }
commonLibraries.from(project.configurations.minecraftImplementation)
commonLibraries.from(project.configurations.installer)
}
tasks.register('launcherJson', LauncherJson).configure {
json.putAll([
mainClass: 'net.minecraftforge.bootstrap.ForgeBootstrap',
arguments: [
game: [
'--launchTarget', 'forge_client'
],
jvm: [
'-Djava.net.preferIPv6Addresses=system'
]
]
] as LinkedHashMap)
}
tasks.register('officialClassesOnly', Zip).configure {
dependsOn(jar)
destinationDirectory = file('build/libs')
archiveClassifier = 'official-classes'
from zipTree(jar.archiveFile).matching {
include '**/*.class'
exclude 'mcp/**'
}
}
tasks.named('filterJarNew').configure {
dependsOn('officialClassesOnly')
input = officialClassesOnly.archiveFile
}
tasks.register('filterJarNewSRG', FilterNewJar).configure {
input = reobfJar.output
srg = filterJarNew.srg
blacklist = filterJarNew.blacklist
}
tasks.named('universalJar').configure {
dependsOn downloadCrowdin
from zipTree(downloadCrowdin.dest).matching {
include 'assets/forge/lang/*.json'
}
from(EXTRA_TXTS)
duplicatesStrategy = 'exclude'
exclude '.cache'
manifest {
attributes([
'Automatic-Module-Name': 'net.minecraftforge.forge'
] as LinkedHashMap)
attributes([
'Specification-Title' : 'Forge',
'Specification-Vendor' : 'Forge Development LLC',
'Specification-Version' : SPEC_VERSION,
'Implementation-Title' : project.group,
'Implementation-Vendor' : 'Forge Development LLC',
'Implementation-Version': FORGE_VERSION
] as LinkedHashMap, 'net/minecraftforge/versions/forge/')
attributes([
'Specification-Title' : 'Minecraft',
'Specification-Vendor' : 'Forge Development LLC',
'Specification-Version' : MC_VERSION,
'Implementation-Title' : 'MCP',
'Implementation-Vendor' : 'Forge Development LLC',
'Implementation-Version': MCP_VERSION
] as LinkedHashMap, 'net/minecraftforge/versions/mcp/')
attributes([
'Specification-Title' : 'Mohist',
'Specification-Vendor' : 'MohistMC',
'Specification-Version' : MOHIST_VERSION,
'Implementation-Title' : 'Mohist',
'Implementation-Version': MC_VERSION + '-' + MOHIST_VERSION,
'Implementation-Vendor' : 'MohistMC'
] as LinkedHashMap, 'com/mohistmc/mohist/')
attributes([
'Specification-Title' : MCP_VERSION,
'Specification-Vendor' : 'SpigotMC',
'Specification-Version' : MC_VERSION,
'Implementation-Title' : 'Spigot',
'Implementation-Version': bukkit_version + '-' + craftbukkit_version + '-' + spigot_version + '-' + forge_version,
'Implementation-Vendor' : 'SpigotMC'
] as LinkedHashMap, 'org/bukkit/craftbukkit/')
}
jarSigner.sign(it)
}
task downloadMultipleFiles(type: Download) {
src([
'https://maven.mohistmc.com/libraries/1.21.1/mohist/libraries.zip'
])
dest layout.buildDirectory.dir("libraries")
}
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: [genServerBinPatches, project(':bootstrap').tasks.jar, project(':mohistlauncher').tasks.jar]) {
dependsOn(createServerShimConfig)
archiveClassifier = 'server'
archiveExtension = 'jar'
archiveBaseName = 'mohist'
archiveVersion = MC_VERSION + '-' + MOHIST_VERSION
destinationDirectory = file('build/libs')
manifest {
attributes('Class-Path': configurations.bootstrap.resolvedConfiguration.resolvedArtifacts.collect { "libraries/${Util.getMavenInfoFromDep(it).path}" }.join(' '))
attributes([
'Automatic-Module-Name': 'net.minecraftforge.bootstrap.shim',
'Main-Class': 'net.minecraftforge.bootstrap.shim.Main'
])
attributes([
'Specification-Title' : 'BootStrap-Shim',
'Specification-Vendor' : 'Forge Development LLC',
'Implementation-Title' : 'bs-shim',
'Implementation-Version': '2.0.1',
'Implementation-Vendor' : 'Forge Development LLC'
] as LinkedHashMap, 'net/minecraftforge/bootstrap/shim/')
}
//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(':mohistlauncher').tasks.jar.outputs) {
rename { 'data/mohistlauncher-' + MC_VERSION + '.jar' }
}
from(zipTree(project(':bootstrap').tasks.jar.outputs.getFiles().asPath)) {
into ""
}
from(project(':mohistplugins').tasks.jar.outputs) {
rename { 'data/mohistplugins-' + MC_VERSION + '.jar' }
}
from(zipTree(packageLibraries.outputs.getFiles().asPath)) {
into 'META-INF/libraries'
}
from(zipTree(downloadMultipleFiles.outputs.getFiles().asPath)) {
into 'META-INF/libraries'
}
from (createServerShimConfig.output)
from (createServerShimClasspath.output) {
rename { 'bootstrap-shim.list' }
}
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' }
}
jarSigner.sign(it)
}
tasks.register('genAllData') {
dependsOn 'forge_data'
}