Skip to content

Commit 5537dbc

Browse files
authored
Merge pull request #114 from BenCodez/maintenance/verified-dependency-refresh
Update compatible dependencies and Spigot while preserving Redis APIs
2 parents 3abb6e4 + 86abff6 commit 5537dbc

2 files changed

Lines changed: 59 additions & 6 deletions

File tree

‎SimpleAPI/pom.xml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<build.number>NOTSET</build.number>
1616
<mysql.connector.test.group>com.mysql</mysql.connector.test.group>
1717
<mysql.connector.test.artifact>mysql-connector-j</mysql.connector.test.artifact>
18-
<mysql.connector.test.version>9.5.0</mysql.connector.test.version>
18+
<mysql.connector.test.version>26.7.0</mysql.connector.test.version>
1919
<maven.compiler.source>21</maven.compiler.source>
2020
<maven.compiler.target>21</maven.compiler.target>
2121
<maven.compiler.release>21</maven.compiler.release>
@@ -262,7 +262,7 @@
262262
<dependency>
263263
<groupId>org.spigotmc</groupId>
264264
<artifactId>spigot-api</artifactId>
265-
<version>26.2-R0.1-SNAPSHOT</version>
265+
<version>26.3-R0.1-SNAPSHOT</version>
266266
<scope>provided</scope>
267267
</dependency>
268268
<dependency>
@@ -298,7 +298,7 @@
298298
<dependency>
299299
<groupId>org.junit.jupiter</groupId>
300300
<artifactId>junit-jupiter-engine</artifactId>
301-
<version>6.1.2</version>
301+
<version>6.1.3</version>
302302
<scope>test</scope>
303303
</dependency>
304304
<dependency>
@@ -310,7 +310,7 @@
310310
<dependency>
311311
<groupId>org.mockito</groupId>
312312
<artifactId>mockito-core</artifactId>
313-
<version>5.23.0</version>
313+
<version>5.24.0</version>
314314
<scope>test</scope>
315315
</dependency>
316316
<dependency>
@@ -425,7 +425,7 @@
425425
<plugin>
426426
<groupId>org.apache.maven.plugins</groupId>
427427
<artifactId>maven-deploy-plugin</artifactId>
428-
<version>3.1.4</version>
428+
<version>3.2.0</version>
429429
<configuration>
430430
<skip>true</skip>
431431
</configuration>
@@ -516,7 +516,7 @@
516516
<plugin>
517517
<groupId>org.apache.maven.plugins</groupId>
518518
<artifactId>maven-deploy-plugin</artifactId>
519-
<version>3.1.4</version>
519+
<version>3.2.0</version>
520520
<configuration>
521521
<skip>true</skip>
522522
</configuration>

‎SimpleAPI/src/test/java/com/bencodez/simpleapi/tests/packaging/FullArtifactTest.java‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
import static org.junit.jupiter.api.Assertions.*;
44

55
import java.io.File;
6+
import java.io.StringWriter;
7+
import java.net.URLClassLoader;
68
import java.nio.charset.StandardCharsets;
79
import java.nio.file.Files;
810
import java.nio.file.Path;
911
import java.util.concurrent.TimeUnit;
1012
import java.util.jar.Attributes;
1113
import java.util.jar.JarFile;
1214

15+
import javax.tools.ToolProvider;
16+
1317
import org.junit.jupiter.api.Test;
1418
import org.junit.jupiter.api.io.TempDir;
1519

@@ -19,6 +23,55 @@
1923
public class FullArtifactTest {
2024
@TempDir Path temporary;
2125

26+
@Test void legacyRedisConsumerCompilesAndLinksAgainstOnlyTheFullJar() throws Exception {
27+
Path full = fullJar();
28+
Path source = temporary.resolve("LegacyRedisConsumer.java");
29+
Files.writeString(source, """
30+
import java.util.Set;
31+
import redis.clients.jedis.HostAndPort;
32+
import redis.clients.jedis.JedisClientConfig;
33+
import redis.clients.jedis.JedisPooled;
34+
import redis.clients.jedis.JedisSentineled;
35+
import redis.clients.jedis.UnifiedJedis;
36+
37+
public final class LegacyRedisConsumer {
38+
// Compile the established constructor calls without opening a connection.
39+
public static Object[] construct(HostAndPort endpoint, JedisClientConfig config,
40+
Set<HostAndPort> sentinels) {
41+
return new Object[] {
42+
new JedisPooled(endpoint, config),
43+
new JedisSentineled("synthetic-master", config, sentinels, config),
44+
new UnifiedJedis(endpoint, config)
45+
};
46+
}
47+
48+
public static int link() throws Exception {
49+
JedisPooled.class.getConstructor(HostAndPort.class, JedisClientConfig.class);
50+
JedisSentineled.class.getConstructor(String.class, JedisClientConfig.class,
51+
Set.class, JedisClientConfig.class);
52+
UnifiedJedis.class.getConstructor(HostAndPort.class, JedisClientConfig.class);
53+
return 3;
54+
}
55+
}
56+
""");
57+
var compiler = ToolProvider.getSystemJavaCompiler();
58+
assertNotNull(compiler, "Packaged API verification requires the build JDK");
59+
StringWriter diagnostics = new StringWriter();
60+
try (var files = compiler.getStandardFileManager(null, null, StandardCharsets.UTF_8)) {
61+
boolean compiled = compiler.getTask(diagnostics, files, null,
62+
java.util.List.of("--release", "21", "-proc:none", "-classpath", full.toString(),
63+
"-d", temporary.toString()), null,
64+
files.getJavaFileObjects(source.toFile())).call();
65+
assertTrue(compiled, "Legacy Redis consumer must compile using only the packaged JAR: " + diagnostics);
66+
}
67+
// Platform parent excludes every Maven dependency, including any older Jedis on the test classpath.
68+
try (var loader = new URLClassLoader(new java.net.URL[] {
69+
temporary.toUri().toURL(), full.toUri().toURL() }, ClassLoader.getPlatformClassLoader())) {
70+
Class<?> consumer = Class.forName("LegacyRedisConsumer", true, loader);
71+
assertEquals(3, consumer.getMethod("link").invoke(null));
72+
}
73+
}
74+
2275
@Test void omitsExternalCryptoProvider() throws Exception {
2376
Path full = fullJar();
2477
try (JarFile output = new JarFile(full.toFile())) {

0 commit comments

Comments
 (0)