Skip to content

Commit

Permalink
configure mockito agent
Browse files Browse the repository at this point in the history
  • Loading branch information
yannicklamprecht committed Nov 5, 2024
1 parent 92131ad commit ac66afc
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 58 deletions.
29 changes: 27 additions & 2 deletions patches/api/0003-Test-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,41 @@ Subject: [PATCH] Test changes
- Ignore package-private methods for nullability annotations
- Add excludes for classes which don't pass
- Disable stupid BukkitMirrorTest
- configure mockito agent to address changes in newer java versions see https://openjdk.org/jeps/451

Co-authored-by: Riley Park <[email protected]>
Co-authored-by: Jake Potrebic <[email protected]>
Co-authored-by: Yannick Lamprecht <[email protected]>

diff --git a/build.gradle.kts b/build.gradle.kts
index 0b837b485bec96fa37ed65c18df97e55cecd0e9d..c8a8903d1b0c9822743549ecb8e4fdc7d0fd07c1 100644
index 0b837b485bec96fa37ed65c18df97e55cecd0e9d..904ed4978ab8175ff744beaae6eb2d736ca0cb6e 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -107,6 +107,12 @@ tasks.test {
@@ -11,6 +11,7 @@ java {
val annotationsVersion = "24.1.0"
val bungeeCordChatVersion = "1.20-R0.2"

+val mockitoAgent = configurations.create("mockitoAgent") // Paper - configure mockito agent that is needed in newer java versions
dependencies {
// api dependencies are listed transitively to API consumers
api("com.google.guava:guava:32.1.2-jre")
@@ -44,6 +45,7 @@ dependencies {
testImplementation("org.hamcrest:hamcrest:2.2")
testImplementation("org.mockito:mockito-core:5.14.1")
testImplementation("org.ow2.asm:asm-tree:9.7.1")
+ mockitoAgent("org.mockito:mockito-core:5.14.1") { isTransitive = false } // Paper - configure mockito agent that is needed in newer java versions
}

configure<PublishingExtension> {
@@ -105,8 +107,19 @@ tasks.withType<Javadoc> {

tasks.test {
useJUnitPlatform()
+ // Paper start - configure mockito agent that is needed in newer java versions
+ jvmArgumentProviders.add(CommandLineArgumentProvider {
+ listOf("-javaagent:${mockitoAgent.asPath}")
+ })
+ // Paper end - configure mockito agent that is needed in newer java versions
}

+// Paper start - compile tests with -parameters for better junit parameterized test names
Expand Down
8 changes: 4 additions & 4 deletions patches/api/0004-Code-Generation.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Currently includes generated key holder classes for types
used in the Registry Modification API

diff --git a/build.gradle.kts b/build.gradle.kts
index c8a8903d1b0c9822743549ecb8e4fdc7d0fd07c1..032f8b762b552e8cae20bbdd75c1e0844e64386a 100644
index 904ed4978ab8175ff744beaae6eb2d736ca0cb6e..5fa49b629d0dbfc18baf2a3a3fece46b5a583e07 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,6 +1,7 @@
Expand All @@ -18,8 +18,8 @@ index c8a8903d1b0c9822743549ecb8e4fdc7d0fd07c1..032f8b762b552e8cae20bbdd75c1e084
}

java {
@@ -46,6 +47,22 @@ dependencies {
testImplementation("org.ow2.asm:asm-tree:9.7.1")
@@ -48,6 +49,22 @@ dependencies {
mockitoAgent("org.mockito:mockito-core:5.14.1") { isTransitive = false } // Paper - configure mockito agent that is needed in newer java versions
}

+// Paper start
Expand All @@ -41,7 +41,7 @@ index c8a8903d1b0c9822743549ecb8e4fdc7d0fd07c1..032f8b762b552e8cae20bbdd75c1e084
configure<PublishingExtension> {
publications.create<MavenPublication>("maven") {
from(components["java"])
@@ -123,3 +140,14 @@ tasks.check {
@@ -130,3 +147,14 @@ tasks.check {
dependsOn(scanJar)
}
// Paper end
Expand Down
4 changes: 2 additions & 2 deletions patches/api/0005-Add-FastUtil-to-Bukkit.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Add FastUtil to Bukkit
Doesn't expose to plugins, just allows Paper-API to use it for optimization

diff --git a/build.gradle.kts b/build.gradle.kts
index 032f8b762b552e8cae20bbdd75c1e0844e64386a..4b6c5d1ae45d93d88adb7035eb19935361c06178 100644
index bb39806d6d57539e8df390fdcdd5d360f54568eb..ab6dc8a3e81c168c818d0d321a52b5b247596ef7 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -23,6 +23,7 @@ dependencies {
@@ -24,6 +24,7 @@ dependencies {
api("com.googlecode.json-simple:json-simple:1.1.1") {
isTransitive = false // includes junit
}
Expand Down
9 changes: 5 additions & 4 deletions patches/api/0006-Adventure.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Co-authored-by: Jake Potrebic <[email protected]>
Co-authored-by: Yannick Lamprecht <[email protected]>

diff --git a/build.gradle.kts b/build.gradle.kts
index 4b6c5d1ae45d93d88adb7035eb19935361c06178..cce9caa52c9a2208acccbd25fa88c0de066f23a4 100644
index ab6dc8a3e81c168c818d0d321a52b5b247596ef7..9d7cca022286f9f56811e3f9bd69b1093508aa63 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -11,12 +11,28 @@ java {
@@ -11,13 +11,29 @@ java {

val annotationsVersion = "24.1.0"
val bungeeCordChatVersion = "1.20-R0.2"
Expand All @@ -28,6 +28,7 @@ index 4b6c5d1ae45d93d88adb7035eb19935361c06178..cce9caa52c9a2208acccbd25fa88c0de
+ extendsFrom(apiAndDocs)
+}

val mockitoAgent = configurations.create("mockitoAgent") // Paper - configure mockito agent that is needed in newer java versions
dependencies {
// api dependencies are listed transitively to API consumers
api("com.google.guava:guava:32.1.2-jre")
Expand All @@ -41,7 +42,7 @@ index 4b6c5d1ae45d93d88adb7035eb19935361c06178..cce9caa52c9a2208acccbd25fa88c0de
api("org.yaml:snakeyaml:2.2")
api("org.joml:joml:1.10.5")
// Paper start
@@ -24,6 +40,13 @@ dependencies {
@@ -25,6 +41,13 @@ dependencies {
isTransitive = false // includes junit
}
api("it.unimi.dsi:fastutil:8.5.6")
Expand All @@ -55,7 +56,7 @@ index 4b6c5d1ae45d93d88adb7035eb19935361c06178..cce9caa52c9a2208acccbd25fa88c0de
// Paper end

compileOnly("org.apache.maven:maven-resolver-provider:3.9.6")
@@ -100,15 +123,32 @@ tasks.withType<Javadoc> {
@@ -102,15 +125,32 @@ tasks.withType<Javadoc> {
"https://guava.dev/releases/32.1.2-jre/api/docs/",
"https://javadoc.io/doc/org.yaml/snakeyaml/2.2/",
"https://javadoc.io/doc/org.jetbrains/annotations/$annotationsVersion/", // Paper - we don't want Java 5 annotations
Expand Down
4 changes: 2 additions & 2 deletions patches/api/0008-Use-ASM-for-event-executors.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Use ASM for event executors.
Uses method handles for private or static methods.

diff --git a/build.gradle.kts b/build.gradle.kts
index cce9caa52c9a2208acccbd25fa88c0de066f23a4..2b1d08d8e16037f6d17c74ea613eaa2ca36c664e 100644
index 9d7cca022286f9f56811e3f9bd69b1093508aa63..939bb9e24708d6a315605afc6e058f9ace52ba10 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -47,6 +47,9 @@ dependencies {
@@ -48,6 +48,9 @@ dependencies {
apiAndDocs("net.kyori:adventure-text-serializer-legacy")
apiAndDocs("net.kyori:adventure-text-serializer-plain")
apiAndDocs("net.kyori:adventure-text-logger-slf4j")
Expand Down
6 changes: 3 additions & 3 deletions patches/api/0009-Paper-Plugins.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Paper Plugins


diff --git a/build.gradle.kts b/build.gradle.kts
index 2b1d08d8e16037f6d17c74ea613eaa2ca36c664e..940fb51c1f3054465f305e98b13aac49c77e3a91 100644
index 939bb9e24708d6a315605afc6e058f9ace52ba10..0435cad080116def2c12b14ade81f37bbf41818d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -52,7 +52,7 @@ dependencies {
@@ -53,7 +53,7 @@ dependencies {
implementation("org.ow2.asm:asm-commons:9.7.1")
// Paper end

Expand All @@ -17,7 +17,7 @@ index 2b1d08d8e16037f6d17c74ea613eaa2ca36c664e..940fb51c1f3054465f305e98b13aac49
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18")
compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")

@@ -141,6 +141,7 @@ tasks.withType<Javadoc> {
@@ -143,6 +143,7 @@ tasks.withType<Javadoc> {
"https://jd.advntr.dev/text-serializer-plain/$adventureVersion/",
"https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/",
// Paper end
Expand Down
6 changes: 3 additions & 3 deletions patches/api/0067-Allow-plugins-to-use-SLF4J-for-logging.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ it without having to shade it in the plugin and going through
several layers of logging abstraction.

diff --git a/build.gradle.kts b/build.gradle.kts
index 940fb51c1f3054465f305e98b13aac49c77e3a91..6c8464d9e862b1b4dbf7a77e25446aa870803dae 100644
index 0435cad080116def2c12b14ade81f37bbf41818d..725e8436b6d0ee66bbcf1949dfc69da6ca3ab72d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -12,6 +12,8 @@ java {
Expand All @@ -26,7 +26,7 @@ index 940fb51c1f3054465f305e98b13aac49c77e3a91..6c8464d9e862b1b4dbf7a77e25446aa8
val apiAndDocs: Configuration by configurations.creating {
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
@@ -47,6 +49,8 @@ dependencies {
@@ -48,6 +50,8 @@ dependencies {
apiAndDocs("net.kyori:adventure-text-serializer-legacy")
apiAndDocs("net.kyori:adventure-text-serializer-plain")
apiAndDocs("net.kyori:adventure-text-logger-slf4j")
Expand All @@ -35,7 +35,7 @@ index 940fb51c1f3054465f305e98b13aac49c77e3a91..6c8464d9e862b1b4dbf7a77e25446aa8

implementation("org.ow2.asm:asm:9.7.1")
implementation("org.ow2.asm:asm-commons:9.7.1")
@@ -140,6 +144,8 @@ tasks.withType<Javadoc> {
@@ -142,6 +146,8 @@ tasks.withType<Javadoc> {
"https://jd.advntr.dev/text-serializer-legacy/$adventureVersion/",
"https://jd.advntr.dev/text-serializer-plain/$adventureVersion/",
"https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/",
Expand Down
8 changes: 4 additions & 4 deletions patches/api/0464-Brigadier-based-command-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ Subject: [PATCH] Brigadier based command API
Co-authored-by: Jake Potrebic <[email protected]>

diff --git a/build.gradle.kts b/build.gradle.kts
index 6c8464d9e862b1b4dbf7a77e25446aa870803dae..254fd96d3950b4494c7e43547b00b5175ee53c93 100644
index 725e8436b6d0ee66bbcf1949dfc69da6ca3ab72d..dc5ddb38dac668df63a9872adc81afc2f60e2e3c 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -27,6 +27,7 @@ configurations.api {
}
@@ -28,6 +28,7 @@ configurations.api {

val mockitoAgent = configurations.create("mockitoAgent") // Paper - configure mockito agent that is needed in newer java versions
dependencies {
+ api("com.mojang:brigadier:1.2.9") // Paper - Brigadier command api
// api dependencies are listed transitively to API consumers
api("com.google.guava:guava:32.1.2-jre")
api("com.google.code.gson:gson:2.10.1")
@@ -93,9 +94,33 @@ sourceSets {
@@ -95,9 +96,33 @@ sourceSets {
}
}
// Paper end
Expand Down
31 changes: 28 additions & 3 deletions patches/server/0004-Test-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,34 @@ From: Jake Potrebic <[email protected]>
Date: Mon, 13 Feb 2023 14:14:56 -0800
Subject: [PATCH] Test changes

- configure mockito agent to address changes in newer java versions see https://openjdk.org/jeps/451

Co-authored-by: yannnicklamprecht <[email protected]>

diff --git a/build.gradle.kts b/build.gradle.kts
index d4a5229b4df544ff60cdaee80c8ae301faf2a235..41b000aaa71dca3fb392ae657be16e05bd37a178 100644
index d4a5229b4df544ff60cdaee80c8ae301faf2a235..c6556e9967347f046d5e91cc9266316aac18b8e7 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -23,6 +23,7 @@ dependencies {
@@ -5,6 +5,8 @@ plugins {
`maven-publish`
}

+val mockitoAgent = configurations.create("mockitoAgent") // Paper - configure mockito agent that is needed in newer java versions
+
dependencies {
implementation(project(":paper-api"))
implementation("jline:jline:2.12.1")
@@ -22,7 +24,9 @@ dependencies {
testImplementation("org.junit.platform:junit-platform-suite-engine:1.10.0")
testImplementation("org.hamcrest:hamcrest:2.2")
testImplementation("org.mockito:mockito-core:5.14.1")
+ mockitoAgent("org.mockito:mockito-core:5.14.1") { isTransitive = false } // Paper - configure mockito agent that is needed in newer java versions
testImplementation("org.ow2.asm:asm-tree:9.7.1")
+ testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // Paper - CartesianTest
}

paperweight {
@@ -56,6 +57,12 @@ tasks.jar {
@@ -56,6 +60,12 @@ tasks.jar {
}
}

Expand All @@ -30,6 +43,18 @@ index d4a5229b4df544ff60cdaee80c8ae301faf2a235..41b000aaa71dca3fb392ae657be16e05
publishing {
publications.create<MavenPublication>("maven") {
}
@@ -79,6 +89,11 @@ tasks.test {
forkEvery = 1
excludeTags("Slow")
}
+ // Paper start - configure mockito agent that is needed in newer java versions
+ jvmArgumentProviders.add(CommandLineArgumentProvider {
+ listOf("-javaagent:${mockitoAgent.asPath}")
+ })
+ // Paper end - configure mockito agent that is needed in newer java versions
}

fun TaskContainer.registerRunTask(
diff --git a/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java b/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..d8857a05858585113bc7efde3416748effb53d01
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0005-Paper-config-files.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public net.minecraft.server.dedicated.DedicatedServerProperties reload(Lnet/mine
public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES

diff --git a/build.gradle.kts b/build.gradle.kts
index 41b000aaa71dca3fb392ae657be16e05bd37a178..da6b4787fa787e098e4031790e955ce616593ee9 100644
index 56e93fe5180f5c54c462b6b4c25e9e5bdee1acaf..46fae04c2d6bac9b4ab1cf9c0f3e348e8d0ee2bc 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -10,6 +10,7 @@ dependencies {
@@ -12,6 +12,7 @@ dependencies {
implementation("jline:jline:2.12.1")
implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion
implementation("org.ow2.asm:asm-commons:9.7.1")
Expand Down Expand Up @@ -5226,7 +5226,7 @@ index 9cf0c141fefe67893828e300cba4f8a8545ba25f..c8e49c1904c80c4ede40ca5c26efad9b
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);

diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c48b1d5fc73a98eb4967632d8e6e0744961a688f..3882ae04173cd125fe490692a6bc2b4d8b20ff7b 100644
index 60805f6a2badca9b9cdfa54a9273ceba6311b16c..6c8a69b7c1b45549b2c388a8df2258184c587309 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -967,6 +967,7 @@ public final class CraftServer implements Server {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Other changes:
Co-Authored-By: Emilia Kond <[email protected]>

diff --git a/build.gradle.kts b/build.gradle.kts
index da6b4787fa787e098e4031790e955ce616593ee9..02a3dd42d82df410b6a6d22c0350fa3e44ccf70f 100644
index 46fae04c2d6bac9b4ab1cf9c0f3e348e8d0ee2bc..e1abd3078735a7505d81b2a18227fa7d78b3a44b 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,9 +5,29 @@ plugins {
@@ -5,11 +5,31 @@ plugins {
`maven-publish`
}

Expand All @@ -38,6 +38,8 @@ index da6b4787fa787e098e4031790e955ce616593ee9..02a3dd42d82df410b6a6d22c0350fa3e
+}
+val alsoShade: Configuration by configurations.creating
+
val mockitoAgent = configurations.create("mockitoAgent") // Paper - configure mockito agent that is needed in newer java versions

dependencies {
implementation(project(":paper-api"))
- implementation("jline:jline:2.12.1")
Expand All @@ -59,7 +61,7 @@ index da6b4787fa787e098e4031790e955ce616593ee9..02a3dd42d82df410b6a6d22c0350fa3e
implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion
implementation("org.ow2.asm:asm-commons:9.7.1")
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
@@ -79,6 +99,19 @@ tasks.check {
@@ -82,6 +102,19 @@ tasks.check {
dependsOn(scanJar)
}
// Paper end
Expand Down Expand Up @@ -396,7 +398,7 @@ index a70e0ecedc7b70031334bc7fee981bd790ce26a4..56f046bac04205a813441907058c4ce2

this.bans = new UserBanList(PlayerList.USERBANLIST_FILE);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 16a9142bdbbfbbbb69d1486bd119dc610094484b..2affb23b83e4368a94345b36410f23139f5d36c8 100644
index c3fc8b1abe843a19347509947f4b864c1b417800..e497da2dba83779c4ad1c45cea133bddadf61446 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -43,7 +43,7 @@ import java.util.logging.Level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ 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 02a3dd42d82df410b6a6d22c0350fa3e44ccf70f..a6fafa32af547efd912468ca3a5c76d8d193651d 100644
index e1abd3078735a7505d81b2a18227fa7d78b3a44b..279b61ce85bba1d5a2b36b5278854538cca680ce 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -23,7 +23,7 @@ dependencies {
@@ -25,7 +25,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.
*/
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 a6fafa32af547efd912468ca3a5c76d8d193651d..b36f2e9e9980f6d2596c57791e0769c6ce734d11 100644
index 279b61ce85bba1d5a2b36b5278854538cca680ce..6419a078c66a8a69ee9fc807284f55cb58f1bf8a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -34,6 +34,7 @@ dependencies {
@@ -36,6 +36,7 @@ dependencies {
implementation("commons-lang:commons-lang:2.6")
runtimeOnly("org.xerial:sqlite-jdbc:3.46.1.3")
runtimeOnly("com.mysql:mysql-connector-j:9.1.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Subject: [PATCH] Deobfuscate stacktraces in log messages, crash reports, and


diff --git a/build.gradle.kts b/build.gradle.kts
index b36f2e9e9980f6d2596c57791e0769c6ce734d11..c73ab51caa985089ade4df0616ee8d3333632980 100644
index 6419a078c66a8a69ee9fc807284f55cb58f1bf8a..d759f0cb19805b8a8adfa045f1f5ed33e73c3ff1 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -46,6 +46,7 @@ dependencies {
testImplementation("org.mockito:mockito-core:5.14.1")
@@ -49,6 +49,7 @@ dependencies {
mockitoAgent("org.mockito:mockito-core:5.14.1") { isTransitive = false } // Paper - configure mockito agent that is needed in newer java versions
testImplementation("org.ow2.asm:asm-tree:9.7.1")
testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // Paper - CartesianTest
+ implementation("net.neoforged:srgutils:1.0.9") // Paper - mappings handling
Expand Down
Loading

0 comments on commit ac66afc

Please sign in to comment.