[ci skip] Scan built jars for bad method usages (#8051)

This commit is contained in:
Jason 2022-06-27 15:41:59 -07:00 committed by GitHub
parent 0d79b867e5
commit 1bd678c494
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 5 deletions

View file

@ -25,3 +25,12 @@ configure<PublishingExtension> {
from(components["java"])
}
}
val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;")
jarToScan.set(tasks.jar.flatMap { it.archiveFile })
classpath.from(configurations.compileClasspath)
}
tasks.check {
dependsOn(scanJar)
}

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Build system changes
diff --git a/build.gradle.kts b/build.gradle.kts
index b81a893bd5418779544872eb4006adc6b3017a43..044b7c49b569e1170108c912e9307f7fec278762 100644
index b81a893bd5418779544872eb4006adc6b3017a43..0b30b1f1be8818934ba530dd263fe6c9484983e8 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -14,15 +14,27 @@ dependencies {
@ -46,3 +46,42 @@ index b81a893bd5418779544872eb4006adc6b3017a43..044b7c49b569e1170108c912e9307f7f
"https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/",
)
@@ -78,3 +90,14 @@ tasks.withType<Javadoc> {
}
}
}
+
+// Paper start
+val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
+ badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;")
+ jarToScan.set(tasks.jar.flatMap { it.archiveFile })
+ classpath.from(configurations.compileClasspath)
+}
+tasks.check {
+ dependsOn(scanJar)
+}
+// Paper end
diff --git a/src/main/java/io/papermc/paper/annotation/DoNotUse.java b/src/main/java/io/papermc/paper/annotation/DoNotUse.java
new file mode 100644
index 0000000000000000000000000000000000000000..4766e49d819e75e5c2127c698b44078bf2fd6219
--- /dev/null
+++ b/src/main/java/io/papermc/paper/annotation/DoNotUse.java
@@ -0,0 +1,18 @@
+package io.papermc.paper.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.jetbrains.annotations.ApiStatus;
+
+/**
+ * Annotation used to mark methods or constructors which should not be called.
+ *
+ * <p>Separate from {@link Deprecated} to differentiate from the large amount of deprecations.</p>
+ */
+@ApiStatus.Internal
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
+public @interface DoNotUse {
+}

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Build system changes
diff --git a/build.gradle.kts b/build.gradle.kts
index d10ff4a52c22033e2adb2a4e7f2cee98a13ea6c5..e4e9df9283c1a0fd7fff38a5d9b6a51f15e06b7a 100644
index d10ff4a52c22033e2adb2a4e7f2cee98a13ea6c5..5d8a84341ab5be52b5c37737e3f82590f06f6073 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -9,10 +9,9 @@ plugins {
@ -48,6 +48,24 @@ index d10ff4a52c22033e2adb2a4e7f2cee98a13ea6c5..e4e9df9283c1a0fd7fff38a5d9b6a51f
)
for (tld in setOf("net", "com", "org")) {
attributes("$tld/bukkit", "Sealed" to true)
@@ -75,6 +80,17 @@ tasks.shadowJar {
}
}
+// Paper start
+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)
+}
+tasks.check {
+ dependsOn(scanJar)
+}
+// Paper end
+
tasks.test {
exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class")
}
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 95da14060be14c5ed8ffbdc65b405cb346e56f6e..80a8872b927ed9de61f1ee36b7769ce104793443 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Deobfuscate stacktraces in log messages, crash reports, and
diff --git a/build.gradle.kts b/build.gradle.kts
index 708915dfc740360752e7e93b185f469481fdf6e5..6def770d18acc25b9bda1917688039448b36309d 100644
index e260462933a9f7065b2360e6bf9e4ee56069a705..a1a8c4778742584125d6084fa761b1bc86f6a842 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,4 +1,6 @@
@ -31,9 +31,9 @@ index 708915dfc740360752e7e93b185f469481fdf6e5..6def770d18acc25b9bda191768803944
runtimeOnly("org.xerial:sqlite-jdbc:3.36.0.3")
runtimeOnly("mysql:mysql-connector-java:8.0.29")
runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
@@ -93,6 +97,45 @@ tasks.shadowJar {
}
@@ -104,6 +108,45 @@ tasks.check {
}
// Paper end
+// Paper start - include reobf mappings in jar for stacktrace deobfuscation
+abstract class IncludeMappings : BaseTask() {