build: update gradle wrapper add jOOQ & flyway

This commit is contained in:
darksaid98 committed 2023-11-19 09:20:18 +01:00
1 parent bac28097ee
commit 6949e94310
5 files changed
+172 -34

No files matched your search

+143 -13
View File
@@ -1,10 +1,18 @@
import org.jooq.codegen.GenerationTool
import org.jooq.meta.jaxb.Configuration
import org.jooq.meta.jaxb.Database
import org.jooq.meta.jaxb.Generator
import org.jooq.meta.jaxb.Jdbc
import java.time.Instant
plugins { plugins {
`java-library` `java-library`
id("com.github.johnrengelman.shadow") version "8.1.1" // Shades and relocates dependencies, See https://imperceptiblethoughts.com/shadow/introduction/ id("com.github.johnrengelman.shadow") version "8.1.1" // Shades and relocates dependencies, See https://imperceptiblethoughts.com/shadow/introduction/
id("xyz.jpenilla.run-paper") version "2.1.0" // Adds runServer and runMojangMappedServer tasks for testing id("xyz.jpenilla.run-paper") version "2.2.2" // Adds runServer and runMojangMappedServer tasks for testing
id("net.minecrell.plugin-yml.bukkit") version "0.6.0" // Automatic plugin.yml generation id("net.minecrell.plugin-yml.bukkit") version "0.6.0" // Automatic plugin.yml generation
id("io.papermc.paperweight.userdev") version "1.5.5" // Used to develop internal plugins using Mojang mappings id("io.papermc.paperweight.userdev") version "1.5.9" // Used to develop internal plugins using Mojang mappings, See https://github.com/PaperMC/paperweight
id("org.flywaydb.flyway") version "10.0.0" // Database migrations
eclipse eclipse
idea idea
@@ -58,16 +66,15 @@ dependencies {
annotationProcessor("org.jetbrains:annotations:24.0.1") annotationProcessor("org.jetbrains:annotations:24.0.1")
paperweight.paperDevBundle("1.20.2-R0.1-SNAPSHOT") paperweight.paperDevBundle("1.20.2-R0.1-SNAPSHOT")
implementation("space.arim.morepaperlib:morepaperlib:0.4.3") implementation("space.arim.morepaperlib:morepaperlib:latest.release")
implementation("com.github.milkdrinkers:crate:1.1.0") implementation("com.github.milkdrinkers:crate:1.1.0")
implementation("com.github.milkdrinkers:colorparser:2.0.0") implementation("com.github.milkdrinkers:colorparser:2.0.0") {
exclude("net.kyori")
}
implementation("dev.jorel:commandapi-bukkit-shade:9.2.0") implementation("dev.jorel:commandapi-bukkit-shade:9.2.0")
implementation("com.zaxxer:HikariCP:5.0.1")
library("org.mariadb.jdbc:mariadb-java-client:3.1.4")
compileOnly("me.clip:placeholderapi:2.11.4") { compileOnly("me.clip:placeholderapi:2.11.4") {
exclude("me.clip.placeholderapi.libs", "kyori") exclude("me.clip.placeholderapi.libs", "kyori")
} }
@@ -80,9 +87,27 @@ dependencies {
compileOnly("com.github.Gecolay.GSit:core:1.5.0") compileOnly("com.github.Gecolay.GSit:core:1.5.0")
compileOnly(files("lib/HeadsPlus-7.0.14.jar")) compileOnly(files("lib/HeadsPlus-7.0.14.jar"))
compileOnly(files("lib/Skulls.jar")) compileOnly(files("lib/Skulls.jar"))
// Database Dependencies
implementation("com.zaxxer:HikariCP:5.1.0")
library("org.flywaydb:flyway-core:10.0.1")
library("org.flywaydb:flyway-mysql:10.0.1")
library("org.flywaydb:flyway-database-hsqldb:10.0.1")
library("org.jooq:jooq:3.18.7")
// JDBC Drivers
library("org.hsqldb:hsqldb:2.7.2")
library("com.h2database:h2:2.2.224")
library("com.mysql:mysql-connector-j:8.2.0")
library("org.mariadb.jdbc:mariadb-java-client:3.3.0")
} }
tasks { tasks {
// NOTE: Use when developing plugins using Mojang mappings
assemble {
dependsOn(reobfJar)
}
build { build {
dependsOn(shadowJar) dependsOn(shadowJar)
} }
@@ -94,6 +119,13 @@ tasks {
// See https://openjdk.java.net/jeps/247 for more information. // See https://openjdk.java.net/jeps/247 for more information.
options.release.set(17) options.release.set(17)
options.compilerArgs.addAll(arrayListOf("-Xlint:all", "-Xlint:-processing", "-Xdiags:verbose")) options.compilerArgs.addAll(arrayListOf("-Xlint:all", "-Xlint:-processing", "-Xdiags:verbose"))
// Generate jOOQ sources before compilation
dependsOn(project.tasks.named("generateSources"))
}
javadoc {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
} }
processResources { processResources {
@@ -105,24 +137,38 @@ tasks {
archiveClassifier.set("") archiveClassifier.set("")
// Shadow classes // Shadow classes
// helper function to relocate a package into our package fun reloc(originPkg: String, targetPkg: String) = relocate(originPkg, "${mainPackage}.lib.${targetPkg}")
fun reloc(originPkg: String, targetPkg: String) = relocate(originPkg, "${project.group}.lib.${targetPkg}")
reloc("space.arim.morepaperlib", "morepaperlib") reloc("space.arim.morepaperlib", "morepaperlib")
reloc("dev.jorel.commandapi", "commandapi")
reloc("com.github.milkdrinkers.Crate", "crate") reloc("com.github.milkdrinkers.Crate", "crate")
reloc("com.github.milkdrinkers.colorparser", "colorparser") reloc("com.github.milkdrinkers.colorparser", "colorparser")
reloc("dev.jorel.commandapi", "commandapi")
reloc("com.zaxxer.hikari", "hikaricp") reloc("com.zaxxer.hikari", "hikaricp")
mergeServiceFiles {
setPath("META-INF/services/org.flywaydb.core.extensibility.Plugin") // Fix Flyway overriding its own files
}
minimize()
} }
runServer { runServer {
// Configure the Minecraft version for our task. // Configure the Minecraft version for our task.
minecraftVersion("1.20.1") minecraftVersion("1.20.2")
// IntelliJ IDEA debugger setup: https://docs.papermc.io/paper/dev/debugging#using-a-remote-debugger // IntelliJ IDEA debugger setup: https://docs.papermc.io/paper/dev/debugging#using-a-remote-debugger
jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005") jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", "-DPaper.IgnoreJavaVersion=true", "-Dcom.mojang.eula.agree=true", "-DIReallyKnowWhatIAmDoingISwear")
systemProperty("terminal.jline", false) systemProperty("terminal.jline", false)
systemProperty("terminal.ansi", true) systemProperty("terminal.ansi", true)
// Automatically install dependencies
downloadPlugins {
// modrinth("carbon", "2.1.0-beta.21")
// github("jpenilla", "MiniMOTD", "v2.0.13", "minimotd-bukkit-2.0.13.jar")
// hangar("squaremap", "1.2.0")
// url("https://download.luckperms.net/1515/bukkit/loader/LuckPerms-Bukkit-5.4.102.jar")
github("MilkBowl", "Vault", "1.7.3", "Vault.jar")
}
} }
} }
@@ -143,7 +189,91 @@ bukkit { // Options: https://github.com/Minecrell/plugin-yml#bukkit
load = net.minecrell.pluginyml.bukkit.BukkitPluginDescription.PluginLoadOrder.POSTWORLD // STARTUP or POSTWORLD load = net.minecrell.pluginyml.bukkit.BukkitPluginDescription.PluginLoadOrder.POSTWORLD // STARTUP or POSTWORLD
depend = listOf("Vault", "Towny") depend = listOf("Vault", "Towny")
softDepend = listOf("TAB", "Skulls", "HeadsPlus") softDepend = listOf("TAB", "Skulls", "HeadsPlus")
}// Apply custom version arg }
flyway {
url = "jdbc:h2:${project.layout.buildDirectory.get()}/generated/flyway/db;AUTO_SERVER=TRUE;MODE=MySQL;CASE_INSENSITIVE_IDENTIFIERS=TRUE;IGNORECASE=TRUE"
user = "sa"
password = ""
placeholders = mapOf( // Substitute placeholders for flyway
"tablePrefix" to "",
"columnSuffix" to " VIRTUAL",
"tableDefaults" to "",
"uuidType" to "BINARY(16)",
"inetType" to "VARBINARY(16)",
"binaryType" to "BLOB",
"alterViewStatement" to "ALTER VIEW",
)
validateMigrationNaming = true
baselineOnMigrate = true
cleanDisabled = false
locations = arrayOf(
"filesystem:src/main/resources/db/migration",
"classpath:db/migration"
)
}
task("generateSources") {
this.group = "jooq"
val dir = layout.buildDirectory.dir("generated-src/jooq").get()
// Ensure database schema has been prepared by Flyway before generating the jOOQ sources
dependsOn.add(tasks.flywayMigrate)
// Declare Flyway migration scripts as inputs on the jOOQ task
inputs.files(fileTree("src/main/resources/db/migration"), fileTree("src/main/java/${mainPackage}/db/flyway/migration"))
.withPropertyName("migration files")
.withPathSensitivity(PathSensitivity.RELATIVE)
// jOOQ Generation Task
doLast {
GenerationTool.generate(Configuration()
.withLogging(org.jooq.meta.jaxb.Logging.WARN)
.withJdbc(Jdbc()
.withDriver("org.h2.Driver")
.withUrl(flyway.url)
.withUser(flyway.user)
.withPassword(flyway.password)
)
.withGenerator(Generator()
.withName("org.jooq.codegen.DefaultGenerator")
.withDatabase(Database()
.withName("org.jooq.meta.h2.H2Database")
.withIncludes(".*")
.withExcludes("(flyway_schema_history)|(?i:information_schema\\..*)|(?i:system_lobs\\..*)") // Exclude db specific files
.withInputSchema("PUBLIC")
.withSchemaVersionProvider("SELECT :schema_name || '_' || MAX(\"version\") FROM \"flyway_schema_history\"") // Grab version from Flyway
)
.withTarget(org.jooq.meta.jaxb.Target()
.withPackageName("${mainPackage}.db.schema")
.withDirectory(dir.toString())
.withClean(true)
)
)
)
}
// Declare outputs
outputs.dir(dir)
.withPropertyName("jooq generated sources")
sourceSets {
get("main").java.srcDir(dir)
}
// Enable build caching
outputs.cacheIf { true }
}
buildscript {
dependencies {
classpath("org.jooq:jooq:3.18.7")
classpath("org.jooq:jooq-meta:3.18.7")
classpath("org.jooq:jooq-codegen:3.18.7")
classpath("com.h2database:h2:2.2.224")
}
}
// Apply custom version arg
val versionArg = if (hasProperty("customVersion")) val versionArg = if (hasProperty("customVersion"))
(properties["customVersion"] as String).uppercase() // Uppercase version string (properties["customVersion"] as String).uppercase() // Uppercase version string
else else
+4
View File
@@ -0,0 +1,4 @@
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048M
Binary file not shown.
+2 -1
View File
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
Vendored
+23 -20
View File
@@ -83,10 +83,8 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} 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 "${APP_HOME:-./}" > /dev/null && 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"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -116,6 +114,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -132,30 +131,31 @@ location of your Java installation."
fi fi
else else
JAVACMD=java 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 Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. # 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 ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
;;
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. # 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" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
;;
esac esac
fi fi
@@ -175,14 +175,12 @@ if "$cygwin" || "$msys"; then
JAVACMD=$( cygpath --unix "$JAVACMD" ) JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh # Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg; do for arg do
if if
case $arg in #( case $arg in #(
-*) false ;; # don't mess with options #( -*) false ;; # don't mess with options #(
/?*) /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath [ -e "$t" ] ;; #(
[ -e "$t" ]
;; #(
*) false ;; *) false ;;
esac esac
then then
@@ -200,11 +198,15 @@ if "$cygwin" || "$msys"; then
done done
fi fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
# shell script including quotes and variable substitutions, so put them in DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# 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 -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \
@@ -213,7 +215,8 @@ set -- \
"$@" "$@"
# Stop when "xargs" is not available. # Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1; then if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available" die "xargs is not available"
fi fi