Skip to content

Commit

Permalink
Switch from in- to excludes for resource inclusion
Browse files Browse the repository at this point in the history
As nearly all resources found in the vanilla jar are desired to be
included in paper, an include list is not ideal. Instead, this commit
changes the copy resource tasks to an exclude-based filter.

Additionally, this commit now allows consumers of paperweight-core to
configure the exclude list instead of directly defining it in the task
definition.

The configurable exclude list is merged with all source files, defined
through the vanillaJarIncludes property, and the
`META-INF/MANIFEST.MF` file, which breaks decompilation of remapped
jars.
  • Loading branch information
lynxplay committed Mar 9, 2022
1 parent 1ac512a commit 6907cc6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ open class AllTasks(
val copyResources by tasks.registering<CopyResources> {
inputJar.set(applyMergedAt.flatMap { it.outputJar })
vanillaJar.set(extractFromBundler.flatMap { it.serverJar })
includes.set(listOf("/data/**", "/assets/**", "version.json", "yggdrasil_session_pubkey.der", "pack.mcmeta", "flightrecorder-config.jfc"))
excludes.convention(listOf("**/*.class", "/META-INF/**"))

outputJar.set(cache.resolve(FINAL_REMAPPED_JAR))
}
Expand Down
7 changes: 3 additions & 4 deletions paperweight-lib/src/main/kotlin/tasks/CopyResources.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class CopyResources : BaseTask() {
abstract val vanillaJar: RegularFileProperty

@get:Input
abstract val includes: ListProperty<String>
abstract val excludes: ListProperty<String>

@get:OutputFile
abstract val outputJar: RegularFileProperty
Expand All @@ -55,11 +55,10 @@ abstract class CopyResources : BaseTask() {

fs.copy {
from(archives.zipTree(vanillaJar)) {
for (inc in this@CopyResources.includes.get()) {
include(inc)
for (inc in this@CopyResources.excludes.get()) {
exclude(inc)
}
}
into(target)
from(archives.zipTree(inputJar))
into(target)
}
Expand Down

0 comments on commit 6907cc6

Please sign in to comment.