Merge pull request #3 from NotAlexNoyle/master

Fixed runtime errors, updated gradle to 8.11
This commit is contained in:
George Hotten authored and GitHub committed 2025-05-18 16:07:32 +01:00
commit a1b1be53d6
5 files changed
+163 -139

No files matched your search

-126
View File
@@ -1,126 +0,0 @@
plugins {
id 'java' // Tell gradle this is a java project.
id 'com.github.johnrengelman.shadow' version '8.1.1' // Import utility to package libraries into .jar file.
id 'eclipse' // Import eclipse plugin for IDE integration.
}
java {
// Declare java version.
sourceCompatibility = JavaVersion.VERSION_17
}
group = 'uk.hotten.staffog'
version = '1.0-beta'
def apiVersion = "1.19" // Declare minecraft server target version.
processResources {
def props = [
version: version,
apiVersion: apiVersion,
]
inputs.properties props // Indicates to rerun if version changes.
filesMatching("plugin.yml") {
expand props
}
}
repositories {
mavenCentral()
maven {
url "https://repo.purpurmc.org/snapshots" // Get purpur API from purpur maven repository.
}
maven {
url "https://jitpack.io"
}
}
dependencies {
compileOnly 'com.google.code.gson:gson:2.10.1'
compileOnly 'commons-io:commons-io:2.11.0'
compileOnly 'org.apache.commons:commons-pool2:2.11.1'
implementation 'org.jooq:jooq:3.18.4'
compileOnly 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
compileOnly 'org.mariadb.jdbc:mariadb-java-client:3.1.3'
compileOnly 'mysql:mysql-connector-java:8.0.32'
compileOnly 'org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
}
tasks.register('updatePluginYmlVersion') {
doLast {
def file = file('src/main/resources/plugin.yml')
def lines = file.readLines()
lines[2] = "version: ${version}-" + getCurrentGitBranch()
file.write(lines.join("\n"))
}
}
def revertPluginYmlVersion() {
def file = file('src/main/resources/plugin.yml')
def lines = file.readLines()
lines[2] = "version: ${version}"
file.write(lines.join("\n"))
}
def getCurrentGitBranch() {
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD'
standardOutput = stdout
}
if (stdout.toString().toLowerCase().trim().equals("head")) {
return "ogsuite";
}
return stdout.toString().trim()
} catch (ignored) {
return 'unknown'
}
}
shadowJar {
minimize()
archiveClassifier.set(getCurrentGitBranch())
doLast {
revertPluginYmlVersion()
}
}
tasks.shadowJar.configure {
archiveClassifier = null
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ["-parameters"]
options.encoding = 'UTF-8' // Override the system character set with a universal set.
options.fork = true // Enable compilation in a separate daemon process.
}
compileJava.dependsOn updatePluginYmlVersion
+144
View File
@@ -0,0 +1,144 @@
plugins {
id("com.gradleup.shadow") version "8.3.5" // Import shadow API.
java // Tell gradle this is a java project.
eclipse // Import eclipse plugin for IDE integration.
kotlin("jvm") version "2.0.21" // Import kotlin jvm plugin for kotlin/java integration.
}
java {
sourceCompatibility = JavaVersion.VERSION_17 // Declare java version.
}
group = "uk.hotten.staffog" // Declare bundle identifier.
version = "1.0-beta" // Declare plugin version (will be in .jar).
val apiVersion = "1.19" // Declare minecraft server target version.
tasks.named<ProcessResources>("processResources") {
val props = mapOf(
"version" to version,
"apiVersion" to apiVersion
)
inputs.properties(props) // Indicates to rerun if version changes.
filesMatching("plugin.yml") {
expand(props)
}
}
repositories {
mavenCentral()
gradlePluginPortal()
maven {
url = uri("https://repo.purpurmc.org/snapshots")
}
maven {
url = uri("https://repo.purpurmc.org/snapshots")
}
maven {
url = uri("https://jitpack.io")
}
}
dependencies {
compileOnly("com.google.code.gson:gson:2.10.1")
compileOnly("commons-io:commons-io:2.11.0")
compileOnly("org.apache.commons:commons-pool2:2.11.1")
compileOnly("jakarta.xml.bind:jakarta.xml.bind-api:4.0.0")
compileOnly("mysql:mysql-connector-java:8.0.32")
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT")
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
compileOnly("org.projectlombok:lombok:1.18.22")
annotationProcessor("org.projectlombok:lombok:1.18.22")
// implementations will be shaded.
implementation("org.jooq:jooq:3.18.4")
implementation("org.reactivestreams:reactive-streams:1.0.4")
implementation("org.mariadb.jdbc:mariadb-java-client:3.1.3") // JDBC
implementation("io.r2dbc:r2dbc-spi:1.0.0.RELEASE") // R2DBC SPI
implementation("org.mariadb:r2dbc-mariadb:1.3.0") // R2DBC driver
}
// Utility functions
fun revertPluginYmlVersion() {
val yaml = file("src/main/resources/plugin.yml")
val lines = yaml.readLines().toMutableList()
lines[2] = "version: $version"
yaml.writeText(lines.joinToString("\n"))
}
fun getCurrentGitBranch(): String = try {
ProcessBuilder("git", "rev-parse", "--abbrev-ref", "HEAD")
.redirectErrorStream(true)
.start()
.inputStream
.bufferedReader()
.use { it.readText() }
.lowercase()
.trim()
.let { if (it == "head") "ogsuite" else it }
} catch (_: Exception) {
"unknown"
}
// Update plugin.yml before compilation
val updatePluginYmlVersion = tasks.register("updatePluginYmlVersion") {
doLast {
val yaml = file("src/main/resources/plugin.yml")
val lines = yaml.readLines().toMutableList()
lines[2] = "version: $version-${getCurrentGitBranch()}"
yaml.writeText(lines.joinToString("\n"))
}
}
// Ensure reproducible builds.
tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
tasks.shadowJar {
archiveClassifier.set(getCurrentGitBranch())
from("LICENSE") { into("/") }
dependencies {
include(dependency("org.jooq:jooq"))
include(dependency("org.reactivestreams:reactive-streams"))
include(dependency("org.mariadb.jdbc:mariadb-java-client"))
include(dependency("io.r2dbc:r2dbc-spi"))
include(dependency("org.mariadb:r2dbc-mariadb"))
}
minimize {
exclude(dependency("org.mariadb.jdbc:mariadb-java-client"))
exclude(dependency("io.r2dbc:r2dbc-spi"))
exclude(dependency("org.mariadb:r2dbc-mariadb"))
}
doLast { revertPluginYmlVersion() }
}
tasks.named("compileJava") {
dependsOn(updatePluginYmlVersion)
}
tasks.build {
dependsOn(tasks.shadowJar)
}
tasks.jar {
archiveClassifier.set("part")
}
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters")
options.compilerArgs.add("-Xlint:deprecation") // Triggers deprecation warning messages.
options.encoding = "UTF-8"
options.isFork = true
}
kotlin {
jvmToolchain(17)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.GRAAL_VM
}
}
Binary file not shown.
+2 -1
View File
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+17 -12
View File
@@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -144,7 +145,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 +153,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
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# 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.
# 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, 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" \