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 42a1901 commit 52dcbfb
Show file tree
Hide file tree
Showing 21 changed files with 152 additions and 67 deletions.
54 changes: 48 additions & 6 deletions patches/api/0003-Test-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,69 @@ 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..ffa4851c98d30a2ac7d3c5bfa52a1033c682db0d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -107,6 +107,12 @@ tasks.test {
useJUnitPlatform()
@@ -1,3 +1,5 @@
+import org.gradle.kotlin.dsl.newInstance // Paper - configure mockito agent that is needed in newer java versions
+
plugins {
`java-library`
`maven-publish`
@@ -11,6 +13,19 @@ java {
val annotationsVersion = "24.1.0"
val bungeeCordChatVersion = "1.20-R0.2"

+// Paper start - configure mockito agent that is needed in newer java versions
+val mockitoAgent = configurations.register("mockitoAgent")
+abstract class MockitoAgentProvider : CommandLineArgumentProvider {
+ @get:InputFiles
+ @get:CompileClasspath
+ abstract val fileCollection: ConfigurableFileCollection
+
+ override fun asArguments(): Iterable<String> {
+ return listOf("-javaagent:" + fileCollection.files.single().absolutePath)
+ }
+}
+// Paper end - 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 +59,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,7 +121,18 @@ tasks.withType<Javadoc> {

tasks.test {
useJUnitPlatform()
+ // Paper start - configure mockito agent that is needed in newer java versions
+ val provider = objects.newInstance<MockitoAgentProvider>()
+ provider.fileCollection.from(mockitoAgent)
+ jvmArgumentProviders.add(provider)
+ // Paper end - configure mockito agent that is needed in newer java versions
+}
+
+// Paper start - compile tests with -parameters for better junit parameterized test names
+tasks.compileTestJava {
+ options.compilerArgs.add("-parameters")
+}
}
+// Paper end
+
// Paper start
val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;")
diff --git a/src/test/java/io/papermc/paper/testing/EmptyTag.java b/src/test/java/io/papermc/paper/testing/EmptyTag.java
new file mode 100644
index 0000000000000000000000000000000000000000..77154095cfb8b259bdb318e8ff40cb6f559ebc18
Expand Down
10 changes: 5 additions & 5 deletions patches/api/0004-Code-Generation.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ 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 ffa4851c98d30a2ac7d3c5bfa52a1033c682db0d..f026cba0707dbd55b20400c6394a508b9bf942f9 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,6 +1,7 @@
@@ -3,6 +3,7 @@ import org.gradle.kotlin.dsl.newInstance
plugins {
`java-library`
`maven-publish`
+ idea // Paper
}

java {
@@ -46,6 +47,22 @@ dependencies {
testImplementation("org.ow2.asm:asm-tree:9.7.1")
@@ -62,6 +63,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 {
@@ -144,3 +161,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 f026cba0707dbd55b20400c6394a508b9bf942f9..049852eb914e0fa9482b50f0e6a272b244532a46 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -23,6 +23,7 @@ dependencies {
@@ -38,6 +38,7 @@ dependencies {
api("com.googlecode.json-simple:json-simple:1.1.1") {
isTransitive = false // includes junit
}
Expand Down
12 changes: 7 additions & 5 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 049852eb914e0fa9482b50f0e6a272b244532a46..344f1850781f9fb4a237ebd0d5a21ab006756db3 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -11,12 +11,28 @@ java {
@@ -13,6 +13,18 @@ java {

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

dependencies {
// Paper start - configure mockito agent that is needed in newer java versions
val mockitoAgent = configurations.register("mockitoAgent")
@@ -31,7 +43,11 @@ dependencies {
// 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")
Expand All @@ -41,7 +43,7 @@ index 4b6c5d1ae45d93d88adb7035eb19935361c06178..cce9caa52c9a2208acccbd25fa88c0de
api("org.yaml:snakeyaml:2.2")
api("org.joml:joml:1.10.5")
// Paper start
@@ -24,6 +40,13 @@ dependencies {
@@ -39,6 +55,13 @@ dependencies {
isTransitive = false // includes junit
}
api("it.unimi.dsi:fastutil:8.5.6")
Expand All @@ -55,7 +57,7 @@ index 4b6c5d1ae45d93d88adb7035eb19935361c06178..cce9caa52c9a2208acccbd25fa88c0de
// Paper end

compileOnly("org.apache.maven:maven-resolver-provider:3.9.6")
@@ -100,15 +123,32 @@ tasks.withType<Javadoc> {
@@ -116,15 +139,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 344f1850781f9fb4a237ebd0d5a21ab006756db3..e8aa93ff1143ca12fb5f11dcb5e24beb0efbe8cd 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -47,6 +47,9 @@ dependencies {
@@ -62,6 +62,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 e8aa93ff1143ca12fb5f11dcb5e24beb0efbe8cd..e930daacd48d38299ab97035b677c19c76b7e997 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -52,7 +52,7 @@ dependencies {
@@ -67,7 +67,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> {
@@ -157,6 +157,7 @@ tasks.withType<Javadoc> {
"https://jd.advntr.dev/text-serializer-plain/$adventureVersion/",
"https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/",
// Paper end
Expand Down
8 changes: 4 additions & 4 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,10 +14,10 @@ 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 e930daacd48d38299ab97035b677c19c76b7e997..9384972f171c22ee0b1ba207cd3c93d4eb9c71fe 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -12,6 +12,8 @@ java {
@@ -14,6 +14,8 @@ java {
val annotationsVersion = "24.1.0"
val bungeeCordChatVersion = "1.20-R0.2"
val adventureVersion = "4.17.0"
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 {
@@ -62,6 +64,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> {
@@ -156,6 +160,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 9384972f171c22ee0b1ba207cd3c93d4eb9c71fe..4084e46b96224c5618c90a03037653b26fb82d54 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -27,6 +27,7 @@ configurations.api {
}
@@ -42,6 +42,7 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider {
// Paper end - 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 {
@@ -109,9 +110,33 @@ sourceSets {
}
}
// Paper end
Expand Down
42 changes: 39 additions & 3 deletions patches/server/0004-Test-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,45 @@ 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..4c8452ad8d39ca606f71205d628c5c6941ca93f9 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -23,6 +23,7 @@ dependencies {
@@ -5,6 +5,19 @@ plugins {
`maven-publish`
}

+// Paper start - configure mockito agent that is needed in newer java versions
+val mockitoAgent = configurations.register("mockitoAgent")
+abstract class MockitoAgentProvider : CommandLineArgumentProvider {
+ @get:InputFiles
+ @get:CompileClasspath
+ abstract val fileCollection: ConfigurableFileCollection
+
+ override fun asArguments(): Iterable<String> {
+ return listOf("-javaagent:" + fileCollection.files.single().absolutePath)
+ }
+}
+// Paper end - configure mockito agent that is needed in newer java versions
+
dependencies {
implementation(project(":paper-api"))
implementation("jline:jline:2.12.1")
@@ -22,7 +35,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 +71,12 @@ tasks.jar {
}
}

Expand All @@ -30,6 +54,18 @@ index d4a5229b4df544ff60cdaee80c8ae301faf2a235..41b000aaa71dca3fb392ae657be16e05
publishing {
publications.create<MavenPublication>("maven") {
}
@@ -79,6 +100,11 @@ tasks.test {
forkEvery = 1
excludeTags("Slow")
}
+ // Paper start - configure mockito agent that is needed in newer java versions
+ val provider = objects.newInstance<MockitoAgentProvider>()
+ provider.fileCollection.from(mockitoAgent)
+ jvmArgumentProviders.add(provider)
+ // 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 4c8452ad8d39ca606f71205d628c5c6941ca93f9..5092490e3fe34c980a0fd6938766eff87c600fdf 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -10,6 +10,7 @@ dependencies {
@@ -23,6 +23,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 5092490e3fe34c980a0fd6938766eff87c600fdf..be0b76e89c231599e327e91c65906e88321abc3d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,9 +5,29 @@ plugins {
@@ -5,6 +5,12 @@ plugins {
`maven-publish`
}

Expand All @@ -38,6 +38,11 @@ index da6b4787fa787e098e4031790e955ce616593ee9..02a3dd42d82df410b6a6d22c0350fa3e
+}
+val alsoShade: Configuration by configurations.creating
+
// Paper start - configure mockito agent that is needed in newer java versions
val mockitoAgent = configurations.register("mockitoAgent")
abstract class MockitoAgentProvider : CommandLineArgumentProvider {
@@ -20,7 +26,21 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider {

dependencies {
implementation(project(":paper-api"))
- implementation("jline:jline:2.12.1")
Expand All @@ -59,7 +64,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 {
@@ -93,6 +113,19 @@ tasks.check {
dependsOn(scanJar)
}
// Paper end
Expand Down Expand Up @@ -382,7 +387,7 @@ index 3d92c61f7781221cfdc0324d11bd0088954e4a68..84a2c6c397604279ba821286f5c3c855
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(() -> {
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index a70e0ecedc7b70031334bc7fee981bd790ce26a4..56f046bac04205a813441907058c4ce21982d927 100644
index 1333daa8666fe2ec4033a2f57ba6b716fcdd5343..8daa027a94602d7d556cf4fbfc8fcd97caf6bd98 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -162,8 +162,7 @@ public abstract class PlayerList {
Expand All @@ -396,7 +401,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
Loading

0 comments on commit 52dcbfb

Please sign in to comment.