Skip to content

Commit

Permalink
Fixed crashes when building installer jar
Browse files Browse the repository at this point in the history
TODO: fix dependencies pointing at the wrong maven when running the installer jar
  • Loading branch information
Rongmario committed Feb 18, 2023
1 parent 22343fd commit a45a686
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
51 changes: 27 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def sysProps = System.getProperties()
group 'com.cleanroommc'
version props.major_version << '.' << props.minor_version << '.' << props.patch_version

def spec_version = props.new_forge_version.substring(props.new_forge_version.indexOf('.') + 1, props.new_forge_version.lastIndexOf('.'))

println "Running Cleanroom $version"
println "Java: ${ -> sysProps['java.version']} | JVM: ${ -> sysProps['java.vm.version']} | Vendor: ${ -> sysProps['java.vendor']} | Architecture: ${ -> sysProps['os.arch']}"

Expand Down Expand Up @@ -173,7 +175,6 @@ project(':cleanroom') {
}

ext {
mcp_artifact = project(':mcp').mcp.config
version_json = project(':mcp').file('build/mcp/downloadJson/version.json')
}

Expand Down Expand Up @@ -541,13 +542,13 @@ project(':cleanroom') {
'--output', '{output}',
'--patches', '{patches}',
'--srg', '{srg}',
'--legacy',
// '--legacy',
'--clean', '{clean}',
'--dirty', '{dirty}',
'--prefix', 'binpatch/client',
'--clean', genServerBinPatches.cleanJar.get().asFile.path,
'--dirty', genServerBinPatches.dirtyJar.get().asFile.path,
'--prefix', 'binpatch/server'
'--prefix', 'binpatch/server',
])
}
}
Expand Down Expand Up @@ -688,9 +689,9 @@ project(':cleanroom') {
}
}

task launcherJson(dependsOn: ['signUniversalJar']) {
task launcherJson(/*dependsOn: ['signUniversalJar']*/) {
inputs.file {
universalJar.archiveFile
universalJar.archivePath
}
ext {
output = file('build/version.json')
Expand Down Expand Up @@ -737,8 +738,8 @@ project(':cleanroom') {
path: "${project.group.replace('.', '/')}/${project.name}/${project.version}/${project.name}-${project.version}.jar",
// 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
url: '',
sha1: sha1(universalJar.archiveFile),
size: universalJar.archiveFile.length()
sha1: Util.sha1(universalJar.archivePath),
size: universalJar.archivePath.length()
]
]
]
Expand All @@ -757,7 +758,7 @@ project(':cleanroom') {
output = file('build/install_profile.json')
installer_tools = 'net.minecraftforge:installertools:1.1.4' // TODO: Why replace with older version?
}
inputs.file universalJar.archiveFile
inputs.file universalJar.archivePath
inputs.file genClientBinPatches.toolJar
inputs.file launcherJson.output
outputs.file output
Expand All @@ -770,8 +771,8 @@ project(':cleanroom') {
path: "${project.group.replace('.', '/')}/${project.name}/${project.version}/${project.name}-${project.version}.jar",
// 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
url: '',
sha1: sha1(universalJar.archiveFile),
size: universalJar.archiveFile.length()
sha1: Util.sha1(universalJar.archivePath),
size: universalJar.archivePath.length()
]
]
]
Expand All @@ -785,12 +786,12 @@ project(':cleanroom') {
json: '/version.json',
path: "${project.group}:${project.name}:${project.version}",
logo: '/big_logo.png',
minecraft: MC_VERSION,
minecraft: props.minecraft_version,
welcome: "Welcome to the simple ${project.name.capitalize()} installer.",
data: [ ] as Map,
processors: [ ]
]
getClasspath(project, libs, MCP_ARTIFACT.get().descriptor) //Tell it to download mcp_config
Util.getClasspath(project, libs, project(':mcp').mcp.config.get().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()
Expand Down Expand Up @@ -845,17 +846,19 @@ project(':cleanroom') {
classpath.append("libraries/${lib.downloads.artifact.path} ")
}
classpath += "minecraft_server.${props.minecraft_version}.jar"
MANIFESTS.each { pkg, values ->
if (pkg == '/') {
manifest.attributes(values += [
'Main-Class': 'net.minecraftforge.fml.relauncher.ServerLaunchWrapper',
'Class-Path': classpath.toString(),
'Tweak-Class': 'net.minecraftforge.fml.common.launcher.FMLTweaker'
])
} else {
manifest.attributes(values, pkg)
}
}
manifest.attributes([
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Class-Path': classpath.toString(),
'Tweak-Class': 'net.minecraftforge.fml.common.launcher.FMLTweaker'
])
manifest.attributes([
'Specification-Title': props.title,
'Specification-Vendor': props.vendor,
'Specification-Version': spec_version,
'Implementation-Title': project.group,
'Implementation-Version': props.new_forge_version,
'Implementation-Vendor': props.vendor
], 'net/minecraftforge/common/')
}
}

Expand All @@ -864,7 +867,7 @@ project(':cleanroom') {
changing = true
}

task installerJar(type: Zip, dependsOn: [downloadInstaller, installerJson, launcherJson, genClientBinPatches, genServerBinPatches, 'signUniversalJar']) {
task installerJar(type: Zip, dependsOn: [downloadInstaller, installerJson, launcherJson, genClientBinPatches, genServerBinPatches/*, 'signUniversalJar'*/]) {
classifier = 'installer'
extension = 'jar' //Needs to be Zip task to not override Manifest, so set extension
destinationDir = file('build/libs')
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
title = Cleanroom
vendor = CleanroomMC

# Versioning

major_version = 1
Expand All @@ -18,4 +21,4 @@ mcp_version = 20200226.224830
special_source = net.md-5:SpecialSource:1.9.0
special_source_mcp = net.md-5:SpecialSource:1.8.5
binary_patcher = net.minecraftforge:binarypatcher:1.1.1:fatjar
installer_tools = net.minecraftforge:installertools:1.1.11
installer_tools = net.minecraftforge:installertools:1.1.11
Binary file added icon.ico
Binary file not shown.

0 comments on commit a45a686

Please sign in to comment.