Skip to content

Commit

Permalink
Shade the filtered jar, this fixes PaperMC/paperweight#194
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Sep 23, 2023
1 parent 9624451 commit c483d55
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 54 deletions.
45 changes: 28 additions & 17 deletions patches/server/0003-Build-system-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ public net.minecraft.server.packs.VanillaPackResourcesBuilder safeGetPath(Ljava/
Co-authored-by: Jake Potrebic <[email protected]>

diff --git a/build.gradle.kts b/build.gradle.kts
index 91a5d6e9775010336da28ed6e2f6654b0f7248f6..32d475a636d4ba90eeaecfac148143f940cba6e2 100644
index 91a5d6e9775010336da28ed6e2f6654b0f7248f6..f208b05cacd7fa5e7f00f83e93eb35f5a8cfd307 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -9,10 +9,9 @@ plugins {
@@ -6,13 +6,15 @@ plugins {
id("com.github.johnrengelman.shadow")
}

+val shade: Configuration by configurations.creating
+
dependencies {
+ shade(files(tasks.filterProjectDir.flatMap { it.outputJar }))
implementation(project(":paper-api"))
implementation("jline:jline:2.12.1")
- implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") {
Expand All @@ -25,7 +31,7 @@ index 91a5d6e9775010336da28ed6e2f6654b0f7248f6..32d475a636d4ba90eeaecfac148143f9
implementation("commons-lang:commons-lang:2.6")
runtimeOnly("org.xerial:sqlite-jdbc:3.43.0.0")
runtimeOnly("com.mysql:mysql-connector-j:8.1.0")
@@ -23,6 +22,8 @@ dependencies {
@@ -23,6 +25,8 @@ dependencies {

testImplementation("junit:junit:4.13.2")
testImplementation("org.hamcrest:hamcrest-library:1.3")
Expand All @@ -34,15 +40,15 @@ index 91a5d6e9775010336da28ed6e2f6654b0f7248f6..32d475a636d4ba90eeaecfac148143f9
}

val craftbukkitPackageVersion = "1_20_R2" // Paper
@@ -34,6 +35,7 @@ tasks.jar {
@@ -34,6 +38,7 @@ tasks.jar {
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
+ val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main",
"Implementation-Title" to "CraftBukkit",
@@ -42,6 +44,9 @@ tasks.jar {
@@ -42,6 +47,9 @@ tasks.jar {
"Specification-Title" to "Bukkit",
"Specification-Version" to project.version,
"Specification-Vendor" to "Bukkit Team",
Expand All @@ -52,7 +58,7 @@ index 91a5d6e9775010336da28ed6e2f6654b0f7248f6..32d475a636d4ba90eeaecfac148143f9
)
for (tld in setOf("net", "com", "org")) {
attributes("$tld/bukkit", "Sealed" to true)
@@ -49,6 +54,11 @@ tasks.jar {
@@ -49,6 +57,11 @@ tasks.jar {
}
}

Expand All @@ -64,15 +70,27 @@ index 91a5d6e9775010336da28ed6e2f6654b0f7248f6..32d475a636d4ba90eeaecfac148143f9
publishing {
publications.create<MavenPublication>("maven") {
artifact(tasks.shadowJar)
@@ -75,6 +85,17 @@ tasks.shadowJar {
@@ -63,7 +76,7 @@ relocation {
}

tasks.shadowJar {
- configurations = listOf(project.configurations.vanillaServer.get())
+ configurations = listOf(shade)
archiveClassifier.set("mojang-mapped")

for (relocation in relocation.relocations.get()) {
@@ -75,6 +88,20 @@ tasks.shadowJar {
}
}

+// Paper start
+fun removeMcJar(elements: Provider<Set<FileSystemLocation>>): Provider<List<FileSystemLocation>> =
+ elements.map { it.filterNot { file -> file.asFile.endsWith("minecraft.jar") } }
+
+val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
+ badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;")
+ jarToScan.set(tasks.shadowJar.flatMap { it.archiveFile })
+ classpath.from(configurations.compileClasspath)
+ classpath.from(sourceSets.main.flatMap { src -> removeMcJar(src.compileClasspath.elements) })
+}
+tasks.check {
+ dependsOn(scanJar)
Expand All @@ -82,20 +100,13 @@ index 91a5d6e9775010336da28ed6e2f6654b0f7248f6..32d475a636d4ba90eeaecfac148143f9
tasks.test {
exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class")
}
@@ -132,7 +153,14 @@ tasks.registerRunTask("runReobf") {
classpath(runtimeClasspathWithoutVanillaServer)
}
@@ -134,5 +161,7 @@ tasks.registerRunTask("runReobf") {

+val runtimeClasspathForRunDev = sourceSets.main.flatMap { src ->
+ src.runtimeClasspath.elements.map { elements ->
+ elements.filterNot { file -> file.asFile.endsWith("minecraft.jar") }
+ }
+}
tasks.registerRunTask("runDev") {
description = "Spin up a non-relocated Mojang-mapped test server"
- classpath(sourceSets.main.map { it.runtimeClasspath })
+ classpath(tasks.filterProjectDir.flatMap { it.outputJar })
+ classpath(runtimeClasspathForRunDev)
+ classpath(sourceSets.main.flatMap { src -> removeMcJar(src.runtimeClasspath.elements) })
+ jvmArgs("-DPaper.isRunDev=true")
}
diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0004-Test-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Test changes


diff --git a/build.gradle.kts b/build.gradle.kts
index 32d475a636d4ba90eeaecfac148143f940cba6e2..b6f741435b7c63d748b79669d3d8f420db52c3a7 100644
index f208b05cacd7fa5e7f00f83e93eb35f5a8cfd307..ce42d3176b370a0b6fb4336f7bed62aa464ffd1b 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -12,6 +12,7 @@ dependencies {
@@ -15,6 +15,7 @@ dependencies {
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
implementation("org.ow2.asm:asm:9.5")
implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0005-Paper-config-files.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public org.spigotmc.SpigotWorldConfig getString(Ljava/lang/String;Ljava/lang/Str
public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES

diff --git a/build.gradle.kts b/build.gradle.kts
index b6f741435b7c63d748b79669d3d8f420db52c3a7..ba38153a37e864ab7f02a169da3df8806122aa76 100644
index ce42d3176b370a0b6fb4336f7bed62aa464ffd1b..df6f6e6d8f0b72598a375868321f8e10618a337b 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -13,6 +13,7 @@ dependencies {
@@ -16,6 +16,7 @@ dependencies {
implementation("org.ow2.asm:asm:9.5")
implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
testImplementation("org.mockito:mockito-core:4.9.0") // Paper - switch to mockito
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ Other changes:
Co-Authored-By: Emilia Kond <[email protected]>

diff --git a/build.gradle.kts b/build.gradle.kts
index ba38153a37e864ab7f02a169da3df8806122aa76..2f562d2fb02d58551338b055a0dd6c05df44e532 100644
index df6f6e6d8f0b72598a375868321f8e10618a337b..2f4e515bc6498ea9c79f95462500a9b53064c017 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -6,9 +6,30 @@ plugins {
id("com.github.johnrengelman.shadow")
@@ -7,11 +7,30 @@ plugins {
}

val shade: Configuration by configurations.creating
+val log4jPlugins = sourceSets.create("log4jPlugins")
+configurations.named(log4jPlugins.compileClasspathConfigurationName) {
+ extendsFrom(configurations.compileClasspath.get())
+}
+val alsoShade: Configuration by configurations.creating
+

dependencies {
shade(files(tasks.filterProjectDir.flatMap { it.outputJar }))
implementation(project(":paper-api"))
- implementation("jline:jline:2.12.1")
+ // Paper start
Expand All @@ -55,20 +55,11 @@ index ba38153a37e864ab7f02a169da3df8806122aa76..2f562d2fb02d58551338b055a0dd6c05
+ runtimeOnly("org.apache.logging.log4j:log4j-core:2.19.0")
+ log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - Needed to generate meta for our Log4j plugins
+ runtimeOnly(log4jPlugins.output)
+ alsoShade(log4jPlugins.output)
+ shade(log4jPlugins.output)
+ // Paper end
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
implementation("org.ow2.asm:asm:9.5")
implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
@@ -75,7 +96,7 @@ relocation {
}

tasks.shadowJar {
- configurations = listOf(project.configurations.vanillaServer.get())
+ configurations = listOf(project.configurations.vanillaServer.get(), alsoShade)
archiveClassifier.set("mojang-mapped")

for (relocation in relocation.relocations.get()) {
diff --git a/src/log4jPlugins/java/io/papermc/paper/console/StripANSIConverter.java b/src/log4jPlugins/java/io/papermc/paper/console/StripANSIConverter.java
new file mode 100644
index 0000000000000000000000000000000000000000..91547f6e6fe90006713beb2818da634304bdd236
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ This may cause additional prefixes to be disabled for plugins bypassing
the plugin logger.

diff --git a/build.gradle.kts b/build.gradle.kts
index 2f562d2fb02d58551338b055a0dd6c05df44e532..7002a2ccb519ede29244924062f7ed2f49546f7d 100644
index 2f4e515bc6498ea9c79f95462500a9b53064c017..b91c5e17f87c94e531a98f2102d7ceaa6be826d8 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -25,7 +25,7 @@ dependencies {
@@ -26,7 +26,7 @@ dependencies {
all its classes to check if they are plugins.
Scanning takes about 1-2 seconds so adding this speeds up the server start.
*/
- runtimeOnly("org.apache.logging.log4j:log4j-core:2.19.0")
+ implementation("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - implementation
log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - Needed to generate meta for our Log4j plugins
runtimeOnly(log4jPlugins.output)
alsoShade(log4jPlugins.output)
shade(log4jPlugins.output)
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 0a0aa6de31a94a701074cc5f43c94be7515a185c..489ce6f439778b26eb33ede9432681d4bf9e0116 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Use AsyncAppender to keep logging IO off main thread


diff --git a/build.gradle.kts b/build.gradle.kts
index 7002a2ccb519ede29244924062f7ed2f49546f7d..7cb7a4024f53c50d88652cb6c497d815ed67c148 100644
index b91c5e17f87c94e531a98f2102d7ceaa6be826d8..1b75ed4d5043b96236eff5d8f8d7afbd8112df44 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -38,6 +38,7 @@ dependencies {
@@ -39,6 +39,7 @@ dependencies {
implementation("commons-lang:commons-lang:2.6")
runtimeOnly("org.xerial:sqlite-jdbc:3.43.0.0")
runtimeOnly("com.mysql:mysql-connector-j:8.1.0")
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0295-Implement-Brigadier-Mojang-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Adds CommandRegisteredEvent
- Allows manipulating the CommandNode to add more children/metadata for the client

diff --git a/build.gradle.kts b/build.gradle.kts
index 7cb7a4024f53c50d88652cb6c497d815ed67c148..7f005b9a41064f1929e8d9cb53c5ab207d3a333d 100644
index 1b75ed4d5043b96236eff5d8f8d7afbd8112df44..a243b3576cb2db7bf1652c4f60fdff2b977bc5b1 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -14,6 +14,7 @@ val alsoShade: Configuration by configurations.creating

@@ -15,6 +15,7 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
dependencies {
shade(files(tasks.filterProjectDir.flatMap { it.outputJar }))
implementation(project(":paper-api"))
+ implementation(project(":paper-mojangapi"))
// Paper start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ Subject: [PATCH] Deobfuscate stacktraces in log messages, crash reports, and


diff --git a/build.gradle.kts b/build.gradle.kts
index 7f005b9a41064f1929e8d9cb53c5ab207d3a333d..dfb43cf7be60733f3ab142de66139971bca1b1fe 100644
index a243b3576cb2db7bf1652c4f60fdff2b977bc5b1..3fbe04fac5ac570e43a44939850ebec3d1c6ae15 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -37,6 +37,7 @@ dependencies {
@@ -38,6 +38,7 @@ dependencies {
testImplementation("org.mockito:mockito-core:4.9.0") // Paper - switch to mockito
implementation("org.spongepowered:configurate-yaml:4.1.2") // Paper - config files
implementation("commons-lang:commons-lang:2.6")
+ implementation("net.fabricmc:mapping-io:0.3.0") // Paper - needed to read mappings for stacktrace deobfuscation
runtimeOnly("org.xerial:sqlite-jdbc:3.43.0.0")
runtimeOnly("com.mysql:mysql-connector-j:8.1.0")
runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
@@ -121,6 +122,18 @@ tasks.check {
@@ -125,6 +126,18 @@ tasks.check {
}
// Paper end

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0391-Implement-Mob-Goal-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Implement Mob Goal API


diff --git a/build.gradle.kts b/build.gradle.kts
index dfb43cf7be60733f3ab142de66139971bca1b1fe..b81b99a7767e3b0d3549e49529e98efdb7334101 100644
index 3fbe04fac5ac570e43a44939850ebec3d1c6ae15..e50102692446d4cf249ff36389ac1d80be69ea41 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -46,6 +46,7 @@ dependencies {
@@ -47,6 +47,7 @@ dependencies {
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Use Velocity compression and cipher natives


diff --git a/build.gradle.kts b/build.gradle.kts
index b81b99a7767e3b0d3549e49529e98efdb7334101..7df1b44674ba5e826ad7c96c9d242865a3282307 100644
index e50102692446d4cf249ff36389ac1d80be69ea41..f64c15b9b8139967a0b071d596f87313c3767bad 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -41,6 +41,11 @@ dependencies {
@@ -42,6 +42,11 @@ dependencies {
runtimeOnly("org.xerial:sqlite-jdbc:3.43.0.0")
runtimeOnly("com.mysql:mysql-connector-j:8.1.0")
runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0810-Add-support-for-Proxy-Protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Subject: [PATCH] Add support for Proxy Protocol


diff --git a/build.gradle.kts b/build.gradle.kts
index 7df1b44674ba5e826ad7c96c9d242865a3282307..26618ddf85952694ae2c78f41a19e4b9a324f059 100644
index f64c15b9b8139967a0b071d596f87313c3767bad..c8db27cab9047b7cdcbe5e83e1c7ad838b9c8f13 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -30,6 +30,7 @@ dependencies {
@@ -31,6 +31,7 @@ dependencies {
log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - Needed to generate meta for our Log4j plugins
runtimeOnly(log4jPlugins.output)
alsoShade(log4jPlugins.output)
shade(log4jPlugins.output)
+ implementation("io.netty:netty-codec-haproxy:4.1.87.Final") // Paper - Add support for proxy protocol
// Paper end
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
Expand Down

0 comments on commit c483d55

Please sign in to comment.