Skip to content

Commit

Permalink
Update build to Java 21
Browse files Browse the repository at this point in the history
Includes:
- Updated maven plugins
- Upgrade Mockito tests
- Updated build script
  • Loading branch information
minoneer committed Dec 22, 2024
1 parent 17995a9 commit ec30086
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 109 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
run: |
cd uSkyBlock-Core/src/main/po && perl en2pirate.pl && cd -
cd uSkyBlock-Core/src/main/po && perl en2kitteh.pl && cd -
- name: JDK 17
- name: JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Install gettext
run: sudo apt-get install -y gettext
Expand Down
15 changes: 0 additions & 15 deletions bukkit-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>16</release>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
Expand All @@ -75,7 +69,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<show>public</show>
<failOnError>false</failOnError>
Expand All @@ -93,7 +86,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand Down Expand Up @@ -125,13 +117,6 @@
<version>${vaultapi.version}</version>
<optional>true</optional>
</dependency>
<!-- DEPRECATED -->
<!-- <dependency>-->
<!-- <groupId>com.googlecode.json-simple</groupId>-->
<!-- <artifactId>json-simple</artifactId>-->
<!-- <version>1.1.1</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;

Expand All @@ -13,7 +12,7 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;

Expand All @@ -27,11 +26,9 @@ public static void setUp() {
mycmd.add(new AbstractCommand("hello|h", "myplugin.perm.hello", "say hello to the player") {
@Override
public boolean execute(CommandSender sender, String alias, Map<String, Object> data, String... args) {
sender.sendMessage(new String[]{
"Hello! and welcome " + sender.getName(),
"I was called with : " + alias,
"I had " + args.length + " arguments: " + Arrays.asList(args)
});
sender.sendMessage("Hello! and welcome " + sender.getName(),
"I was called with : " + alias,
"I had " + args.length + " arguments: " + Arrays.asList(args));
return true;
}
});
Expand Down Expand Up @@ -62,26 +59,22 @@ private void addPerm(CommandSender sender, String s) {
when(sender.hasPermission(ArgumentMatchers.isA(String.class))).thenReturn(true);
}

private void addOp(CommandSender sender) {
when(sender.isOp()).thenReturn(true);
}

private CommandSender createCommandSender() {
CommandSender mock = Mockito.mock(CommandSender.class);
Answer<Void> answer = invocationOnMock -> {
for (Object o : invocationOnMock.getArguments()) {
if (o != null && o.getClass().isArray()) {
for (Object o2 : (Object[]) o) {
messages.append("" + o2 + "\n");
messages.append(o2).append("\n");
}
} else {
messages.append("" + o + "\n");
messages.append(o).append("\n");
}
}
return null;
};
doAnswer(answer).when(mock).sendMessage(anyString());
doAnswer(answer).when(mock).sendMessage(Matchers.<String[]>any());
doAnswer(answer).when(mock).sendMessage(ArgumentMatchers.any(String[].class));
return mock;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import java.util.UUID;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;

public class CompositeCommandTest {
private static UUID ownerUUID = UUID.randomUUID();
private static UUID adminUUID = UUID.randomUUID();
private static UUID modUUID = UUID.randomUUID();
private static final UUID ownerUUID = UUID.randomUUID();
private static final UUID adminUUID = UUID.randomUUID();
private static final UUID modUUID = UUID.randomUUID();
private static BaseCommandExecutor executor;

@BeforeClass
Expand Down Expand Up @@ -89,7 +89,7 @@ public void PermOnAdmin() {
executor.onCommand(player, null, "alias", new String[]{"admin", "sub"});

verify(player).sendMessage("executed admin");
assertThat(messages, Matchers.contains(new String[]{"executed admin", "§eYou do not have access (§4perm.sub§e)"}));
assertThat(messages, Matchers.contains("executed admin", "§eYou do not have access (§4perm.sub§e)"));
}

@Test
Expand All @@ -103,7 +103,7 @@ public void AllPerms() {
executor.onCommand(player, null, "alias", new String[]{"admin", "sub"});

verify(player).sendMessage("executed admin");
assertThat(messages, Matchers.contains(new String[]{"executed admin", "from sub"}));
assertThat(messages, Matchers.contains("executed admin", "from sub"));
}

@Test
Expand All @@ -116,7 +116,7 @@ public void NoPerm_PermissionOverride() {
// Act
executor.onCommand(player, null, "alias", new String[]{"admin", "sub"});

assertThat(messages, Matchers.contains(new String[]{"executed admin", "from sub"}));
assertThat(messages, Matchers.contains("executed admin", "from sub"));
}

@Test
Expand All @@ -129,7 +129,7 @@ public void NoPerm_PermissionSubOverride() {
// Act
executor.onCommand(player, null, "alias", new String[]{"admin", "sub"});

assertThat(messages, Matchers.contains(new String[]{"§eYou do not have access (§4plugin§e)"}));
assertThat(messages, Matchers.contains("§eYou do not have access (§4plugin§e)"));
}

@Test
Expand All @@ -145,7 +145,7 @@ public void BasePerm_PermissionCompositeOverride() {
// Act
executor.onCommand(player, null, "alias", new String[]{"admin", "sub"});

assertThat(messages, Matchers.contains(new String[]{"executed admin", "from sub"}));
assertThat(messages, Matchers.contains("executed admin", "from sub"));
}

@Test
Expand All @@ -162,7 +162,7 @@ public void BasePerm_PermissionAbstractCommandOverride() {
// Act
executor.onCommand(player, null, "alias", new String[]{"admin", "sub2"});

assertThat(messages, Matchers.contains(new String[]{"executed admin", "from sub2"}));
assertThat(messages, Matchers.contains("executed admin", "from sub2"));
}

private List<String> recordMessages(Player player) {
Expand All @@ -175,4 +175,4 @@ private List<String> recordMessages(Player player) {
return messages;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.Objects;
import java.util.TreeMap;

import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;

public class BukkitServerMock {
Expand Down
5 changes: 1 addition & 4 deletions po-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>17</release>
<encoding>utf-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
31 changes: 21 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<hamcrest.version>2.2</hamcrest.version>
<junit.version>4.13.2</junit.version>
<junit-vintage-engine.version>5.9.0</junit-vintage-engine.version>
<mockito.version>3.12.4</mockito.version>
<mockito.version>5.14.2</mockito.version>
</properties>

<modules>
Expand Down Expand Up @@ -69,48 +69,59 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.13.0</version>
<configuration>
<release>17</release>
<release>21</release>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<version>3.11.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0</version>
<version>3.5.0</version>
<executions>
<execution>
<id>enforce-maven</id>
Expand Down
14 changes: 6 additions & 8 deletions uSkyBlock-API/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>uSkyBlock</artifactId>
<groupId>ovh.uskyblock</groupId>
<version>3.1.0-SNAPSHOT</version>
</parent>
<groupId>com.github.rlf</groupId>
<artifactId>uSkyBlock-API</artifactId>
<version>3.1.0-SNAPSHOT</version>
Expand Down Expand Up @@ -31,7 +36,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<version>${spigotapi.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand All @@ -47,20 +52,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<show>public</show>
<failOnError>false</failOnError>
Expand All @@ -84,7 +83,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand Down
5 changes: 1 addition & 4 deletions uSkyBlock-APIv2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>17</release>
<encoding>utf-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Loading

0 comments on commit ec30086

Please sign in to comment.