Configure mockito agent (#11560)

This commit is contained in:
Yannick Lamprecht 2024-11-09 22:49:07 +01:00 committed by GitHub
parent bcbd10804f
commit e47f79acd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 138 additions and 60 deletions

View file

@ -7,16 +7,52 @@ 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 <rileysebastianpark@gmail.com>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Yannick Lamprecht <yannicklamprecht@live.de>
diff --git a/build.gradle.kts b/build.gradle.kts
index 0b837b485bec96fa37ed65c18df97e55cecd0e9d..c8a8903d1b0c9822743549ecb8e4fdc7d0fd07c1 100644
index 0b837b485bec96fa37ed65c18df97e55cecd0e9d..c7f660d52e1b5f085919a8aebf8476918705a391 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -107,6 +107,12 @@ tasks.test {
@@ -11,6 +11,18 @@ 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: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 +56,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 +118,19 @@ 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