diff --git a/Dockerfile b/Dockerfile index 7781667..7d99ba8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM openjdk:17-alpine AS gradle_build -RUN apk add --no-cache sqlite +FROM eclipse-temurin:21 AS gradle_build +RUN apt-get -y update && apt-get install -y sqlite3 COPY . / RUN ["./gradlew", "-si", "build", "installDist"] -FROM openjdk:17-alpine +FROM eclipse-temurin:21-alpine RUN apk add --no-cache sqlite RUN addgroup -g 1001 -S cassette_deck && adduser -u 1001 -S cassette_deck -G cassette_deck RUN mkdir /cassette_deck && chown -R cassette_deck:cassette_deck /cassette_deck diff --git a/README.md b/README.md index 1fbdaf0..73366b3 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ cassette-deck ============= A server to provide various metadata about Minecraft versions. -Requires Java 17 to build. +Requires Java 21 to build. diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e0d8930..fcbc1ea 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -10,7 +10,7 @@ plugins { } java { - toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + toolchain.languageVersion.set(JavaLanguageVersion.of(21)) } tasks.withType { diff --git a/app/src/main/java/org/enginehub/cassettedeck/data/upstream/DataGeneratorExecutor.java b/app/src/main/java/org/enginehub/cassettedeck/data/upstream/DataGeneratorExecutor.java index 153394d..4bb3bea 100644 --- a/app/src/main/java/org/enginehub/cassettedeck/data/upstream/DataGeneratorExecutor.java +++ b/app/src/main/java/org/enginehub/cassettedeck/data/upstream/DataGeneratorExecutor.java @@ -21,6 +21,8 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.enginehub.cassettedeck.data.blob.LibraryStorage; import org.springframework.stereotype.Component; import org.springframework.util.FileSystemUtils; @@ -36,6 +38,7 @@ import java.util.stream.Collectors; public class DataGeneratorExecutor { + private static final Logger LOGGER = LogManager.getLogger(); private static final String JAVA_EXECUTABLE = ProcessHandle.current().info().command() .orElseThrow(() -> new IllegalStateException("Don't know the java executable for this process")); private static final Lock GENERATOR_LOCK = new ReentrantLock(); @@ -68,7 +71,7 @@ private List prepareClassPath() throws IOException { private void runGenerator(String... args) throws IOException { List classPath = prepareClassPath(); - Process process = new ProcessBuilder( + ProcessBuilder processBuilder = new ProcessBuilder( new ImmutableList.Builder() .add(JAVA_EXECUTABLE) .add("-Xms64M", "-Xmx4G") @@ -78,8 +81,9 @@ private void runGenerator(String... args) throws IOException { .add(args) .build() ) - .inheritIO() - .start(); + .inheritIO(); + LOGGER.info("Running data gen: {}", processBuilder.command()); + Process process = processBuilder.start(); try { int exitCode = process.waitFor(); if (exitCode != 0) { diff --git a/app/src/main/java/org/enginehub/cassettedeck/data/upstream/ExtraMetadataLoader.java b/app/src/main/java/org/enginehub/cassettedeck/data/upstream/ExtraMetadataLoader.java index a7d34cf..e6867fa 100644 --- a/app/src/main/java/org/enginehub/cassettedeck/data/upstream/ExtraMetadataLoader.java +++ b/app/src/main/java/org/enginehub/cassettedeck/data/upstream/ExtraMetadataLoader.java @@ -103,7 +103,11 @@ public Result load(MinecraftVersionEntry entry) throws DownloadException { int dataVersion; MojangBlockStates blockStates; try { - try (var zf = new ZipFile(new SeekableInMemoryByteChannel(minecraftJarBytes))) { + try ( + var zf = ZipFile.builder() + .setSeekableByteChannel(new SeekableInMemoryByteChannel(minecraftJarBytes)) + .get() + ) { dataVersion = getDataVersion(entry, zf); if (doDataGen) { if (zf.getEntry("net/minecraft/data/Main.class") == null) { diff --git a/app/src/main/resources/application.properties b/app/src/main/resources/application.properties index b7ad1e5..8b079eb 100644 --- a/app/src/main/resources/application.properties +++ b/app/src/main/resources/application.properties @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +spring.threads.virtual.enabled=true minecraft-version.poll.interval=P1D diff --git a/docker/start.sh b/docker/start.sh index c960cce..ee29255 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -11,4 +11,4 @@ if ! [ -f storage/database.sqlite ]; then done fi fi -./bin/app "$@" +exec ./bin/app "$@" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 87b88e4..170e2b8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,15 +1,15 @@ [versions] -jooq = "3.18.5" +jooq = "3.19.10" [plugins] -spring-boot = "org.springframework.boot:3.1.2" +spring-boot = "org.springframework.boot:3.3.1" licenser = "org.cadixdev.licenser:0.6.1" -jooq = "nu.studer.jooq:8.2.1" +jooq = "nu.studer.jooq:9.0" [libraries] -jetbrains-annotations = "org.jetbrains:annotations:24.0.1" +jetbrains-annotations = "org.jetbrains:annotations:24.1.0" spring-boot-starter-web.module = "org.springframework.boot:spring-boot-starter-web" spring-boot-starter-tomcat.module = "org.springframework.boot:spring-boot-starter-tomcat" @@ -19,17 +19,17 @@ spring-boot-starter-security.module = "org.springframework.boot:spring-boot-star spring-boot-starter-log4j2.module = "org.springframework.boot:spring-boot-starter-log4j2" spring-boot-starter-test.module = "org.springframework.boot:spring-boot-starter-test" -bucket4j-core = "com.github.vladimir-bukhtoyarov:bucket4j-core:7.6.0" +bucket4j-core = "com.github.vladimir-bukhtoyarov:bucket4j-core:8.0.1" -apache-commons-compress = "org.apache.commons:commons-compress:1.23.0" +apache-commons-compress = "org.apache.commons:commons-compress:1.26.2" -guava = "com.google.guava:guava:32.1.1-jre" +guava = "com.google.guava:guava:33.2.1-jre" -xerial-sqlite = "org.xerial:sqlite-jdbc:3.42.0.0" +xerial-sqlite = "org.xerial:sqlite-jdbc:3.46.0.0" -disruptor = "com.lmax:disruptor:3.4.4" +disruptor = "com.lmax:disruptor:4.0.0" -junit-bom = "org.junit:junit-bom:5.10.0" +junit-bom = "org.junit:junit-bom:5.10.3" junit-jupiter-api.module = "org.junit.jupiter:junit-jupiter-api" junit-jupiter-engine.module = "org.junit.jupiter:junit-jupiter-engine" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 033e24c..2c35211 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9f4197d..09523c0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index fcb6fca..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -83,7 +85,9 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -144,7 +148,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -201,11 +205,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/jooq-extensions/build.gradle.kts b/jooq-extensions/build.gradle.kts index b0878e8..3a53951 100644 --- a/jooq-extensions/build.gradle.kts +++ b/jooq-extensions/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } java { - toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + toolchain.languageVersion.set(JavaLanguageVersion.of(21)) withJavadocJar() withSourcesJar() }