-
Notifications
You must be signed in to change notification settings - Fork 82
/
build.gradle
261 lines (222 loc) · 8.76 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
import com.google.common.io.ByteStreams
import org.parchmentmc.compass.CompassPlugin
import org.parchmentmc.compass.tasks.GenerateExport
import org.parchmentmc.compass.tasks.GenerateSanitizedExport
import org.parchmentmc.compass.tasks.VersionDownload
import java.time.OffsetDateTime
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
plugins {
id 'java-base'
id 'maven-publish'
id 'org.parchmentmc.compass' version '0.10.0'
id 'org.parchmentmc.writtenbooks' version '0.5.+'
}
group = 'org.parchmentmc.data'
final releaseType = project.findProperty('releaseType') ?: 'local'
final date = OffsetDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern('yyyy.MM.dd'))
final isRelease = releaseType.toString() == 'release'
version = date + (isRelease ? '' : "-${releaseType}-SNAPSHOT")
final isBleeding = releaseType.toString() == 'bleeding'
if (isBleeding) {
version = 'BLEEDING-SNAPSHOT'
}
// Only output if not in CI
if (!Boolean.parseBoolean(System.getenv("CI"))){
println("Version: $version")
}
writtenbooks {
snapshotVersion = !isRelease
bleedingVersion = isBleeding
githubRepo = 'ParchmentMC/Parchment'
}
compass {
version = '1.21.1'
}
repositories {
maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'FabricMC'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'QuiltMC <333'
url = 'https://maven.quiltmc.org/repository/release/'
}
// remove when ASM 9.8 is released
maven {
name = 'OW2 Snapshots for Enigma'
url = "https://repository.ow2.org/nexus/content/repositories/snapshots/"
}
}
configurations {
enigma
remapper
}
dependencies {
// MCPConfig for the SRG intermediate
mcpconfig 'de.oceanlabs.mcp:mcp_config:1.19.3-20221207.122022'
// ForgeAutoRenamingTool, for remapping the client JAR
remapper 'net.minecraftforge:ForgeAutoRenamingTool:1.0.2'
// Enigma, gorgeous interface for editing mappings
enigma 'org.quiltmc:enigma-swing:2.5.2'
// ParchmentJAM, JAMMER integration for migrating mapping data
jammer 'org.parchmentmc.jam:jam-parchment:0.1.0'
}
tasks.register('printGHActionsOutput') {
doLast {
println("CI_VERSION=${project.version}")
println("CI_GROUP=${project.group}")
println("CI_ARTIFACT=parchment-${project.compass.version.get()}")
println("CI_GAME_VERSION=${project.compass.version.get()}")
}
}
final downloadClientJar = tasks.register('downloadClientJar', VersionDownload) {
group 'parchment'
description 'Downloads the client JAR for the current version set in Compass.'
}
final remapJar = tasks.register('remapJar', RemapJar) {
dependsOn downloadClientJar
final obfDL = project.plugins.getPlugin(CompassPlugin).obfuscationMapsDownloader
inputJar = downloadClientJar.flatMap { it.outputFile }
mappings = obfDL.getObfuscationMap().flatMap { s -> obfDL.clientDownloadOutput }
outputJar = project.layout.buildDirectory.dir('remapped')
.zip(project.compass.version) { d, ver -> d.file("$ver-client.jar") }
logFile = project.layout.buildDirectory.dir('remapped')
.map { d -> d.file('log.txt') }
}
tasks.register('enigma', EnigmaExec) {
inputJar = remapJar.flatMap { it.outputJar }
mappings = project.compass.productionData
}
tasks.withType(GenerateExport).configureEach {
// Disable blackstone if UPDATING is set.
// This will ensure cascaded method data does not get mixed into the production data when updating.
useBlackstone = !Boolean.valueOf(project.findProperty('UPDATING')?.toString())
}
tasks.register('generateSanitizedExport', GenerateSanitizedExport) {
group = 'compass'
description = "Generates an export file using the 'official' intermediate provider and production data."
input = project.compass.productionData
inputFormat = project.compass.productionDataFormat
}
tasks.register('officialExportZip', Zip) {
group = 'build'
description = "Creates a ZIP archive containing the export produced by the 'official' intermediate provider and production data."
from(tasks.named('generateOfficialExport', GenerateExport).flatMap { it.output })
archiveBaseName = 'officialExport'
}
tasks.register('officialSanitizedExportZip', Zip) {
group = 'build'
description = "Creates a ZIP archive containing the sanitized export produced by the 'official' intermediate provider and production data."
from(tasks.named('generateSanitizedExport', GenerateExport).flatMap { it.output })
archiveBaseName = 'officialSanitizedExport'
}
tasks.register('officialStagingExportZip', Zip) {
group = 'build'
description = "Creates a ZIP archive containing the export produced by the 'official' intermediate provider and staging data."
from(tasks.named('generateOfficialStagingExport', GenerateExport).flatMap { it.output })
archiveBaseName = 'officialStagingExport'
}
tasks.withType(Zip).matching { it.name.startsWith 'official' }.configureEach {
rename { 'parchment.json' }
reproducibleFileOrder = true
preserveFileTimestamps = false
destinationDirectory = project.layout.buildDirectory.dir('exportZips')
}
publishing {
publications.all { p ->
p.pom {
name = 'Parchment Mappings'
description = 'Parameter names and javadoc mappings for Minecraft: Java Edition.'
organization {
name = 'ParchmentMC'
url = 'https://github.com/ParchmentMC'
}
licenses {
license {
name = 'CC0-1.0'
url = 'https://creativecommons.org/publicdomain/zero/1.0/legalcode'
}
}
}
afterEvaluate {
p.artifactId = "parchment-${project.compass.version.get()}"
p.pom.properties['minecraft_version'] = project.compass.version
}
}
publications.register('export', MavenPublication) { p ->
p.artifact tasks.named('officialExportZip', Zip)
p.artifact(tasks.named('officialSanitizedExportZip', Zip)) {
classifier = 'checked'
}
}
publications.register('staging', MavenPublication) { p ->
p.artifact tasks.named('officialStagingExportZip', Zip)
p.version = 'staging-SNAPSHOT'
}
repositories {
maven {
name 'projectLocal'
url "file://${rootProject.file('repo').absolutePath}"
}
}
}
tasks.register('publishExport') {
group = PublishingPlugin.PUBLISH_TASK_GROUP
description = "Publishes the 'export' Maven publication."
dependsOn tasks.withType(PublishToMavenRepository).matching {
it.publication == publishing.publications.export
}
}
abstract class RemapJar extends JavaExec {
@InputFile
abstract RegularFileProperty getInputJar()
@InputFile
abstract RegularFileProperty getMappings()
@OutputFile
abstract RegularFileProperty getOutputJar()
@Console
abstract RegularFileProperty getLogFile()
RemapJar() {
group 'parchment'
description 'Remaps the client JAR with the Mojang obfuscation mappings.'
classpath project.configurations.remapper
mainClass.set 'net.minecraftforge.fart.Main'
standardOutput = ByteStreams.nullOutputStream() // We have a log file in place
args = ['--reverse'] // Input mappings is expected to be OBF->MOJ (ProGuard layout)
argumentProviders.add({ ->
['--input', inputJar.get().asFile.absolutePath,
'--map', mappings.get().asFile.absolutePath,
'--output', outputJar.get().asFile.absolutePath,
'--log', logFile.get().asFile.absolutePath]
} as CommandLineArgumentProvider)
}
}
abstract class EnigmaExec extends JavaExec {
@InputFile
abstract RegularFileProperty getInputJar()
@InputDirectory
abstract DirectoryProperty getMappings()
EnigmaExec() {
group 'parchment'
description 'Runs the Enigma mapping tool.'
classpath project.configurations.enigma
mainClass.set 'org.quiltmc.enigma.gui.Main'
args = ['--no-edit-all', '--edit-parameters', '--edit-javadocs']
argumentProviders.add({ ->
['--jar', inputJar.get().asFile.absolutePath,
'--mappings', mappings.get().asFile.absolutePath]
} as CommandLineArgumentProvider)
// Enigma runs on Java 17. If the Gradle JVM supports Java 17, then we are fine
// If not, then we set the java launcher via JVM toolchain so Gradle downloads a Java 17 JVM
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
javaLauncher.set project.javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
} as Provider<JavaLauncher>
}
}
}