Skip to content

Commit ef8e7d4

Browse files
committed
Dev bundle <=v5: only count AT file as input for AT action, not entire dev bundle
1 parent f21a136 commit ef8e7d4

6 files changed

Lines changed: 37 additions & 16 deletions

File tree

paperweight-lib/src/main/kotlin/io/papermc/paperweight/util/utils.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ interface InputStreamProvider {
344344
return op(input)
345345
}
346346
}
347+
348+
fun string(value: String) = wrap(value.byteInputStream())
347349
}
348350
}
349351

paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/action/WorkGraph.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class WorkGraph(
142142
terminalInputHash
143143
} else {
144144
val inputHashes = node.registration.inputs.hash(hashCache)
145-
inputHashes.map { InputStreamProvider.wrap(it.byteInputStream()) }
145+
inputHashes.map(InputStreamProvider::string)
146146
.hash(HashingAlgorithm.SHA256)
147147
.asHexString()
148148
}

paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/action/values.kt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,32 @@ fun javaLauncherValue(javaLauncher: JavaLauncher): Value<JavaLauncher> = object
154154
javaLauncher.metadata.vendor,
155155
javaLauncher.metadata.languageVersion.asInt().toString(),
156156
).joinToString("\n")
157-
return listOf(InputStreamProvider.wrap(jdkMetadata.byteInputStream()))
157+
return listOf(InputStreamProvider.string(jdkMetadata))
158158
}
159159

160160
override fun toString(): String = "javaLauncherValue('$javaLauncher')"
161161
}
162+
163+
class ZippedFileValue(
164+
val zipFile: Path,
165+
val path: String,
166+
) : Value<Unit> {
167+
override fun get() = Unit
168+
169+
fun extractTo(target: Path, overwrite: Boolean = false) {
170+
useEntry { it.copyTo(target.createParentDirectories(), overwrite) }
171+
}
172+
173+
fun <R> useEntry(op: (Path) -> R): R = zipFile.openZipSafe().use { fs ->
174+
val path = fs.getPath("/").resolve(path)
175+
return op(path)
176+
}
177+
178+
override fun bytes(): List<InputStreamProvider> = listOf(
179+
object : InputStreamProvider {
180+
override fun <T> use(op: (InputStream) -> T): T = useEntry { it.inputStream().use(op) }
181+
}
182+
)
183+
184+
override fun toString(): String = "ZippedFileValue(zipFile='$zipFile', path='$path')"
185+
}

paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/action/AccessTransformMinecraftAction.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import io.papermc.paperweight.tasks.*
2626
import io.papermc.paperweight.userdev.internal.action.FileValue
2727
import io.papermc.paperweight.userdev.internal.action.Input
2828
import io.papermc.paperweight.userdev.internal.action.Output
29-
import io.papermc.paperweight.userdev.internal.action.StringValue
3029
import io.papermc.paperweight.userdev.internal.action.Value
3130
import io.papermc.paperweight.userdev.internal.action.WorkDispatcher
31+
import io.papermc.paperweight.userdev.internal.action.ZippedFileValue
3232
import io.papermc.paperweight.util.*
3333
import kotlin.io.path.*
3434
import org.gradle.jvm.toolchain.JavaLauncher
@@ -37,17 +37,13 @@ import org.gradle.workers.WorkerExecutor
3737
class AccessTransformMinecraftAction(
3838
@Input private val javaLauncher: Value<JavaLauncher>,
3939
private val workerExecutor: WorkerExecutor,
40-
@Input private val bundleZip: FileValue,
41-
@Input val atPath: StringValue,
40+
@Input val at: ZippedFileValue,
4241
@Input private val inputJar: FileValue,
4342
@Output val outputJar: FileValue,
4443
) : WorkDispatcher.Action {
4544
override fun execute() {
4645
val atTmp = outputJar.get().resolveSibling("tmp.at").cleanFile()
47-
bundleZip.get().openZipSafe().use { fs ->
48-
val at = fs.getPath(atPath.get())
49-
at.copyTo(atTmp)
50-
}
46+
at.extractTo(atTmp)
5147
try {
5248
applyAccessTransform(
5349
inputJarPath = inputJar.get(),

paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/v2/SetupHandlerImplV2.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,12 @@ class SetupHandlerImplV2(
150150
AccessTransformMinecraftAction(
151151
javaLauncher,
152152
context.workerExecutor,
153-
bundleZip,
154-
StringValue(bundle.config.buildData.accessTransformFile),
153+
ZippedFileValue(bundle.zip, bundle.config.buildData.accessTransformFile),
155154
fix.outputJar,
156155
dispatcher.outputFile("output.jar"),
157156
)
158157
)
159-
dispatcher.provided(at.atPath)
158+
dispatcher.provided(at.at)
160159

161160
val decompile = dispatcher.register(
162161
"decompileMinecraftServer",
@@ -206,7 +205,7 @@ class SetupHandlerImplV2(
206205
applyPaperclip.outputJar,
207206
dispatcher.outputFile("output.jar"),
208207
value(bundle.config.buildData.relocations) {
209-
listOf(InputStreamProvider.wrap(gson.toJson(it).byteInputStream()))
208+
listOf(InputStreamProvider.string(gson.toJson(it)))
210209
},
211210
)
212211
)

paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/v5/SetupHandlerImplV5.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import io.papermc.paperweight.userdev.PaperweightUserExtension
2626
import io.papermc.paperweight.userdev.internal.action.FileCollectionValue
2727
import io.papermc.paperweight.userdev.internal.action.StringValue
2828
import io.papermc.paperweight.userdev.internal.action.WorkDispatcher
29+
import io.papermc.paperweight.userdev.internal.action.ZippedFileValue
2930
import io.papermc.paperweight.userdev.internal.action.fileValue
3031
import io.papermc.paperweight.userdev.internal.action.javaLauncherValue
3132
import io.papermc.paperweight.userdev.internal.action.stringListValue
@@ -145,13 +146,12 @@ class SetupHandlerImplV5(
145146
AccessTransformMinecraftAction(
146147
javaLauncher,
147148
context.workerExecutor,
148-
bundleZip,
149-
StringValue(bundle.config.buildData.accessTransformFile),
149+
ZippedFileValue(bundle.zip, bundle.config.buildData.accessTransformFile),
150150
fix.outputJar,
151151
dispatcher.outputFile("output.jar"),
152152
)
153153
)
154-
dispatcher.provided(at.atPath)
154+
dispatcher.provided(at.at)
155155

156156
val decompile = dispatcher.register(
157157
"decompileMinecraftServer",

0 commit comments

Comments
 (0)