Skip to content

Commit 77d79c6

Browse files
committed
Use JST for ATs
1 parent 12770f0 commit 77d79c6

File tree

16 files changed

+263
-600
lines changed

16 files changed

+263
-600
lines changed

gradle/libs.versions.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ lorenz = "0.5.8"
44
hypo = "1.2.4"
55
serialize = "1.5.1"
66
feather = "1.1.0"
7-
restamp = "1.2.0"
7+
jst = "1.0.68-inheritance-SNAPSHOT"
88

99
[libraries]
1010
asm-core = { module = "org.ow2.asm:asm", version.ref = "asm" }
@@ -40,7 +40,8 @@ diffpatch = "codechicken:DiffPatch:1.5.0.30"
4040
serialize-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialize" }
4141
serialize-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialize" }
4242

43-
restamp = {module = "io.papermc.restamp:restamp", version.ref = "restamp" }
43+
jst = { module = "io.papermc.jst:jst-cli-bundle", version.ref = "jst" }
44+
# jst = { module = "net.neoforged.jst:jst-cli-bundle", version.ref = "jst" }
4445

4546
# test
4647
mockk = "io.mockk:mockk:1.13.8"

paperweight-core/build.gradle.kts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@ plugins {
33
`config-publish`
44
}
55

6-
val restamp: Configuration by configurations.creating
7-
configurations.implementation {
8-
extendsFrom(restamp)
9-
}
10-
116
dependencies {
127
shade(projects.paperweightLib)
138
shade(project(projects.paperweightLib.path, "sharedRuntime"))
14-
restamp(project(projects.paperweightLib.path, "restampRuntime"))
159

1610
implementation(libs.bundles.kotson)
1711
implementation(libs.coroutines)
@@ -27,9 +21,6 @@ gradlePlugin {
2721
val finalJar = tasks.register("finalJar", Zip::class) {
2822
archiveExtension.set("jar")
2923
from(zipTree(tasks.shadowJar.flatMap { it.archiveFile }))
30-
from(zipTree(restamp.elements.map { it.single() })) {
31-
exclude("META-INF/MANIFEST.MF")
32-
}
3324
}
3425
tasks.assemble {
3526
dependsOn(finalJar)

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SoftSpoonTasks.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
package io.papermc.paperweight.core.taskcontainers
2424

2525
import io.papermc.paperweight.core.ext
26-
import io.papermc.paperweight.restamp.RestampVersion
2726
import io.papermc.paperweight.tasks.*
2827
import io.papermc.paperweight.tasks.mache.DecompileJar
2928
import io.papermc.paperweight.tasks.mache.RemapJar
@@ -74,9 +73,10 @@ open class SoftSpoonTasks(
7473
val macheMinecraftLibraries by project.configurations.registering
7574
val mappedJarOutgoing = project.configurations.consumable("mappedJarOutgoing") // For source generator modules
7675
val macheMinecraft by project.configurations.registering
77-
val restampConfig = project.configurations.register(RESTAMP_CONFIG) {
76+
val jstConfig = project.configurations.register(JST_CONFIG) {
7877
defaultDependencies {
79-
add(project.dependencies.create("io.papermc.restamp:restamp:${RestampVersion.VERSION}"))
78+
// add(project.dependencies.create("net.neoforged.jst:jst-cli-bundle:${JSTVersion.VERSION}"))
79+
add(project.dependencies.create("io.papermc.jst:jst-cli-bundle:${JSTVersion.VERSION}"))
8080
}
8181
}
8282

@@ -131,7 +131,6 @@ open class SoftSpoonTasks(
131131

132132
mache.from(project.configurations.named(MACHE_CONFIG))
133133
macheOld.set(project.ext.macheOldPath)
134-
minecraftClasspath.from(macheMinecraftLibraries)
135134
inputFile.set(macheDecompileJar.flatMap { it.outputJar })
136135
predicate.set { Files.isRegularFile(it) && it.toString().endsWith(".java") }
137136
}
@@ -140,9 +139,11 @@ open class SoftSpoonTasks(
140139
description = "Setup vanilla source dir (applying mache patches and paper ATs)."
141140
configureSetupMacheSources()
142141
libraryImports.set(importLibraryFiles.flatMap { it.outputDir })
143-
ats.set(mergeCollectedAts.flatMap { it.outputFile })
144142
outputDir.set(layout.cache.resolve(BASE_PROJECT).resolve("sources"))
145-
restamp.from(restampConfig)
143+
144+
atFile.set(mergeCollectedAts.flatMap { it.outputFile })
145+
ats.jstClasspath.from(macheMinecraftLibraries)
146+
ats.jst.from(jstConfig)
146147
}
147148

148149
val setupMacheSourcesForDevBundle by tasks.registering(SetupVanilla::class) {
@@ -216,16 +217,15 @@ open class SoftSpoonTasks(
216217
group = "softspoon"
217218
description = "Rebuilds patches to the vanilla sources"
218219

219-
minecraftClasspath.from(macheMinecraft)
220-
atFile.set(project.ext.paper.additionalAts.fileExists(project))
221-
atFileOut.set(project.ext.paper.additionalAts.fileExists(project))
222-
223220
base.set(layout.cache.resolve(BASE_PROJECT).resolve("sources"))
224221
input.set(layout.projectDirectory.dir("src/vanilla/java"))
225222
patches.set(project.ext.paper.sourcePatchDir)
226223
gitFilePatches.set(project.ext.gitFilePatches)
227224

228-
restamp.from(restampConfig)
225+
ats.jstClasspath.from(macheMinecraft)
226+
ats.jst.from(jstConfig)
227+
atFile.set(project.ext.paper.additionalAts.fileExists(project))
228+
atFileOut.set(project.ext.paper.additionalAts.fileExists(project))
229229
}
230230

231231
val rebuildResourcePatches by tasks.registering(RebuildFilePatches::class) {

paperweight-lib/build.gradle.kts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,15 @@ val sharedJar by tasks.creating(Jar::class) {
1515
tasks.jar {
1616
from(shared.output)
1717
}
18-
val restamp = sourceSets.create("restamp") {
18+
sourceSets.main {
1919
blossom {
2020
kotlinSources {
21-
properties.put("restamp_version", libs.versions.restamp)
21+
properties.put("jst_version", libs.versions.jst)
2222
}
2323
}
2424
}
25-
val restampJar by tasks.creating(Jar::class) {
26-
archiveClassifier = "restamp"
27-
from(restamp.output)
28-
}
2925

3026
configurations {
31-
consumable("restampRuntime") {
32-
outgoing.artifact(restampJar)
33-
}
3427
consumable("sharedRuntime") {
3528
outgoing.artifact(sharedJar)
3629
}
@@ -42,14 +35,6 @@ dependencies {
4235
compileOnly(shared.output)
4336
testImplementation(shared.output)
4437

45-
restamp.implementationConfigurationName(libs.restamp)
46-
restamp.implementationConfigurationName(shared.output)
47-
restamp.compileOnlyConfigurationName(gradleApi())
48-
restamp.compileOnlyConfigurationName(gradleKotlinDsl())
49-
compileOnly(restamp.output)
50-
testImplementation(restamp.output)
51-
testImplementation(libs.restamp)
52-
5338
implementation(libs.httpclient)
5439
implementation(libs.bundles.kotson)
5540
implementation(libs.coroutines)

paperweight-lib/src/restamp/kotlin-templates/io/papermc/paperweight/restamp/RestampVersion.kt.peb renamed to paperweight-lib/src/main/kotlin-templates/io/papermc/paperweight/util/JSTVersion.kt.peb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
* USA
2121
*/
2222

23-
package io.papermc.paperweight.restamp
23+
package io.papermc.paperweight.util
2424

25-
object RestampVersion {
26-
const val VERSION: String = "{{ restamp_version }}"
25+
object JSTVersion {
26+
const val VERSION: String = "{{ jst_version }}"
2727
}

paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/mache/SetupVanilla.kt

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ package io.papermc.paperweight.tasks.mache
2525
import codechicken.diffpatch.cli.PatchOperation
2626
import codechicken.diffpatch.util.LoggingOutputStream
2727
import codechicken.diffpatch.util.archiver.ArchiveFormat
28-
import io.papermc.paperweight.restamp.SetupVanillaRestampWorker
29-
import io.papermc.paperweight.restamp.setSnappyTempDir
3028
import io.papermc.paperweight.tasks.*
29+
import io.papermc.paperweight.tasks.softspoon.ApplySourceATs
3130
import io.papermc.paperweight.util.*
3231
import java.nio.file.Path
3332
import java.util.function.Predicate
@@ -58,19 +57,10 @@ abstract class SetupVanilla : JavaLauncherTask() {
5857
@get:OutputDirectory
5958
abstract val outputDir: DirectoryProperty
6059

61-
@get:Optional
62-
@get:InputFile
63-
@get:PathSensitive(PathSensitivity.NONE)
64-
abstract val ats: RegularFileProperty
65-
6660
@get:Optional
6761
@get:InputDirectory
6862
abstract val libraryImports: DirectoryProperty
6963

70-
@get:Optional
71-
@get:CompileClasspath
72-
abstract val minecraftClasspath: ConfigurableFileCollection
73-
7464
@get:Optional
7565
@get:Classpath
7666
abstract val mache: ConfigurableFileCollection
@@ -82,8 +72,12 @@ abstract class SetupVanilla : JavaLauncherTask() {
8272
@get:Inject
8373
abstract val workerExecutor: WorkerExecutor
8474

85-
@get:CompileClasspath
86-
abstract val restamp: ConfigurableFileCollection
75+
@get:Nested
76+
val ats: ApplySourceATs = objects.newInstance()
77+
78+
@get:InputFile
79+
@get:Optional
80+
abstract val atFile: RegularFileProperty
8781

8882
@TaskAction
8983
fun run() {
@@ -165,27 +159,22 @@ abstract class SetupVanilla : JavaLauncherTask() {
165159
logger.lifecycle("Applied ${result.summary.changedFiles} mache patches")
166160
}
167161

168-
if (ats.isPresent) {
169-
val classPath = minecraftClasspath.files.map { it.toPath() }.toMutableList()
170-
classPath.add(outputPath)
171-
162+
if (atFile.isPresent) {
172163
println("Applying access transformers...")
173-
174-
val queue = workerExecutor.processIsolation {
175-
forkOptions {
176-
maxHeapSize = "2G"
177-
executable(launcher.get().executablePath.path.absolutePathString())
178-
classpath.from(restamp)
179-
setSnappyTempDir(temporaryDir)
180-
}
181-
}
182-
queue.submit(SetupVanillaRestampWorker::class) {
183-
this.ats.set(this@SetupVanilla.ats.pathOrNull)
184-
this.outputPath.set(outputPath)
185-
this.classpath.from(classPath)
164+
// TODO - No way to tell JST to ignore the .git dir
165+
val gitTmp = outputPath.resolveSibling(outputPath.name + "_.git_tmp")
166+
outputPath.resolve(".git").moveTo(gitTmp)
167+
try {
168+
ats.run(
169+
launcher.get(),
170+
outputPath,
171+
outputPath,
172+
atFile.path,
173+
temporaryDir.toPath(),
174+
)
175+
} finally {
176+
gitTmp.moveTo(outputPath.resolve(".git"))
186177
}
187-
queue.await()
188-
189178
commitAndTag(git, "ATs")
190179
}
191180

paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/softspoon/ApplySourceAT.kt

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)