-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shade the filtered jar, this fixes PaperMC/paperweight#194
- Loading branch information
Showing
11 changed files
with
56 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") { | ||
|
@@ -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") | ||
|
@@ -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", | ||
|
@@ -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 { | ||
} | ||
} | ||
|
||
|
@@ -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) | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters