-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
121 lines (98 loc) · 3.68 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import java.nio.file.Path
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.StandardCopyOption
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
maven { url "https://maven.fabricmc.net" }
maven { url "https://repo.sleeping.town" }
}
dependencies {
classpath "com.unascribed:voldeloom:1.0.2+1.4.7"
}
}
apply plugin: "java"
apply plugin: "com.unascribed.voldeloom"
java {
toolchain {
//Last version able to set a --release as low as 6.
languageVersion = JavaLanguageVersion.of(11)
}
}
compileJava {
//Required to target old versions of Forge correctly.
options.release.set(6)
}
//Goofy Zone ~Ten Desires~ (modified a lot from the buildcraft one)
def forgeVersion = "1.4.7-6.6.2.534"
def minecraftVersion = "1.4.7"
def mcp = "mcp726a.zip"
def forgeSource = "forge${forgeVersion}-src.zip"
def mcpForged = "mcp726a-forged.zip"
void get(File file, String url) {
println "Downloading ${url} to ${file}... (might take a bit)"
file.withOutputStream { it << new URL(url).openStream() }
if(file.length() == 0) throw new IllegalStateException("${url} downloaded as 0 bytes. Archive.org sometimes returns 0-byte files on 404s, double-check the url?")
}
if(!file(mcp).exists()) get(file(mcp), "https://archive.org/download/minecraftcoderpack/minecraftcoderpack.zip/minecraftcoderpack%2F${minecraftVersion}%2F${mcp}")
if(!file(forgeSource).exists()) get(file(forgeSource), "https://maven.minecraftforge.net/net/minecraftforge/forge/${forgeVersion}/forge-${forgeVersion}-src.zip")
if(!file(mcpForged).exists()) {
println "Merging Forge config into MCP..."
Path mcpZipPath = file(mcp).toPath()
Path forgeZipPath = file(forgeSource).toPath()
Path mcpForgedPath = file(mcpForged).toPath()
Files.copy(mcpZipPath, mcpForgedPath, StandardCopyOption.REPLACE_EXISTING)
//modify the zip in-place with zip filesystem.
//Take forge's mcp config (located at forge.zip/forge/fml/conf) and paste it over mcp.zip (at mcp726a-forged.zip/conf)
//Why the ClassLoader type ascription? Because of this https://bugs.openjdk.org/browse/JDK-8223197
FileSystems.newFileSystem(mcpForgedPath, (ClassLoader) null).withCloseable {mcpForgedFs ->
FileSystems.newFileSystem(forgeZipPath, (ClassLoader) null).withCloseable {forgeZipFs ->
Files.walk(forgeZipFs.getPath("/forge/fml/conf")).forEach {src ->
if (Files.isRegularFile(src)) {
Path dst = mcpForgedFs.getPath(src.toString().substring("/forge/fml".length())) //hopefully this works lol
println "Copying ${src} (${src.fileSystem}) into ${dst} (${dst.fileSystem})"
Files.createDirectories(dst.parent)
Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING)
}
}
}
}
}
//end goofy zone
group = "agency.highlysuspect"
archivesBaseName = "hopper"
version = "1.0"
repositories {
maven {
url = "https://maven.minecraftforge.net/"
content {
includeGroup "net.minecraftforge"
//Gradle 5 and above, by default, assume an artifact doesn't exist
//if it can't find a maven_metadata.xml, to cut down on the amount
//of spurious 404 requests. But Forge doesn't publish any maven pom
//files for their old versions. This opts in to the old behavior.
metadataSources {
artifact()
}
}
}
}
dependencies {
minecraft "com.mojang:minecraft:1.4.7"
forge "net.minecraftforge:forge:${forgeVersion}:universal@zip"
//noinspection GradlePackageUpdate, hahahahhaaaaaaahaha
implementation "com.google.guava:guava:12.0.1"
mappings files(mcpForged)
}
processResources {
inputs.property "version", project.version
filesMatching(["**/mcmod.info", "**/mods.toml"]) {
expand "version": project.version
}
}
tasks.jar.dependsOn(processResources)
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}