Skip to content

Commit

Permalink
1.12.2 build script overhaul.
Browse files Browse the repository at this point in the history
- Updated to ForgeGradle 4.0, MixinGradle 0.7 and Gradle 6.9.4
- Added a hack to run the game on arm64 on Mac OS X natively.
  • Loading branch information
0-x-2-2 committed Jun 17, 2023
1 parent 800cb2e commit cb7c2d7
Show file tree
Hide file tree
Showing 12 changed files with 404 additions and 320 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ baritone_Client.launch

.vscode/launch.json

libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar
libs/java-objc-bridge-1.1.jar
136 changes: 91 additions & 45 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ buildscript {
repositories {
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
url = 'https://files.minecraftforge.net/maven'
}
maven {
name = 'SpongePowered'
Expand All @@ -32,18 +32,19 @@ buildscript {
}

dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:4.+' // TODO: 5.+. `doHackyStuff` relies on 4.x internals.
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}


import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
apply plugin: 'maven-publish'
apply plugin: 'net.minecraftforge.gradle'
apply from: 'hacks.gradle'
ext.doHackyStuff(Class.forName('net.minecraftforge.gradle.mcp.task.GenerateSRG')) // TODO: fg 5.0 - `ext.doHackyStuff(Class.forName('net.minecraftforge.gradle.mcp.tasks.GenerateSRG'))`
apply plugin: 'org.spongepowered.mixin'

sourceCompatibility = targetCompatibility = '1.8'
Expand All @@ -53,8 +54,19 @@ compileJava {
}

sourceSets {
api {
compileClasspath += main.compileClasspath
}
main {
compileClasspath += api.output
}
test {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
}
launch {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
}

schematica_api {
Expand All @@ -67,13 +79,26 @@ sourceSets {
}

minecraft {
version = '1.12.2'
mappings = 'stable_39'
tweakClass = 'baritone.launch.BaritoneTweaker'
runDir = 'run'

// The sources jar should use SRG names not MCP to ensure compatibility with all mappings
makeObfSourceJar = true
mappings channel: 'stable', version: '39-1.12'
runs {
def nativesOutput = extractNatives.output // TODO: fg 5.0 - `def nativesOutput = extractNatives.output.get()`
println("[Baritoe] Detected natives: ${nativesOutput}")
client {
workingDirectory project.file('run')
source sourceSets.launch

main 'net.minecraft.launchwrapper.Launch'

args '--gameDir', '.'
args '--version', '1.12.2'
args '--assetsDir', downloadAssets.output
args '--assetIndex', '{asset_index}'
args '--accessToken', 'INVALID'

args '--tweakClass', 'baritone.launch.BaritoneTweaker'
jvmArgs "-Dorg.lwjgl.librarypath=${nativesOutput}"
}
}
}

repositories {
Expand All @@ -95,23 +120,66 @@ repositories {
}
}

// fix forge gradle 4+ bug with 1.12.2
afterEvaluate {
configurations.minecraft {
exclude group: 'net.minecraftforge', module: 'mergetool'
}
}

// lwjgl2 hack for running game on arm64 mac os
afterEvaluate {
def os = org.gradle.internal.os.OperatingSystem.current()
if (os.isMacOsX()) {
def arch = System.getProperty("os.arch").toLowerCase()
println("Detected Mac OS X running on ${arch}")
if (arch == "aarch64") {
println("Configurating aarch64 dependencies.")

configurations.minecraft {
exclude group: 'ca.weblite', module: 'java-objc-bridge'
}

dependencies {
// https://github.com/MinecraftMachina/lwjgl/releases/download/2.9.4-20150209-mmachina.2/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar
minecraft files("libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar") // TODO: use prism launcher maven
// https://github.com/MinecraftMachina/Java-Objective-C-Bridge/releases/download/1.1.0-mmachina.1/java-objc-bridge-1.1.jar
minecraft files("libs/java-objc-bridge-1.1.jar") // TODO: use prism launcher maven
minecraft(group: 'net.java.dev.jna', name: 'jna') {
version {
strictly '5.12.1'
}
}
}
}
}
}

dependencies {
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
minecraft group: 'net.minecraft', name: 'joined', version: '1.12.2'
implementation(group: 'net.minecraft', name: 'launchwrapper', version: '1.12') {
transitive = false
}

def asmVersion = '9.5'
implementation group: 'org.ow2.asm', name: 'asm', version: asmVersion
implementation group: 'org.ow2.asm', name: 'asm-tree', version: asmVersion
implementation group: 'org.ow2.asm', name: 'asm-commons', version: asmVersion
implementation group: 'org.ow2.asm', name: 'asm-analysis', version: asmVersion
implementation group: 'org.ow2.asm', name: 'asm-util', version: asmVersion

launchImplementation('com.github.ImpactDevelopment:SimpleTweaker:1.2')
launchImplementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
transitive = false
}
runtime launchCompile('dev.babbaj:nether-pathfinder:0.2')
launchAnnotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
launchImplementation('dev.babbaj:nether-pathfinder:0.2')
testImplementation 'junit:junit:4.12'
implementation 'dev.babbaj:nether-pathfinder:0.2'
}

mixin {
defaultObfuscationEnv searge
add sourceSets.launch, 'mixins.baritone.refmap.json'
}

Expand All @@ -137,7 +205,7 @@ jar {
manifest {
attributes(
'MixinConfigs': 'mixins.baritone.json',

'TweakClass': 'baritone.launch.BaritoneTweaker',
'Implementation-Title': 'Baritone',
'Implementation-Version': version
)
Expand All @@ -152,25 +220,3 @@ task proguard(type: ProguardTask) {
task createDist(type: CreateDistTask, dependsOn: proguard)

build.finalizedBy(createDist)

install {
def jarApiName = String.format("%s-api-%s", rootProject.name, version.toString())
def jarApiForgeName = String.format("%s-api-forge-%s", rootProject.name, version.toString())
def jarSAName = String.format("%s-standalone-%s", rootProject.name, version.toString())
def jarSAForgeName = String.format("%s-standalone-forge-%s", rootProject.name, version.toString())

artifacts {
archives file("$buildDir/libs/" + jarApiName + ".jar")
archives file("$buildDir/libs/" + jarApiForgeName + ".jar")
archives file("$buildDir/libs/" + jarSAName + ".jar")
archives file("$buildDir/libs/" + jarSAForgeName + ".jar")
}
repositories.mavenInstaller {
addFilter('api') { artifact, file -> artifact.name == "baritone-api" }
addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" }
addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" }
addFilter('standalone-forge') { artifact, file -> artifact.name == "baritone-standalone-forge" }
}
}

install.dependsOn(build)
4 changes: 2 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ repositories {
}

dependencies {
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
}
Loading

0 comments on commit cb7c2d7

Please sign in to comment.