mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 14:38:55 +00:00
build: update db stuff from upstream template
This commit is contained in:
1 file changed
+60
-66
+60
-66
@@ -1,8 +1,6 @@
|
||||
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 org.flywaydb.gradle.task.FlywayMigrateTask
|
||||
import org.jooq.codegen.gradle.CodegenTask
|
||||
import org.jooq.meta.jaxb.Logging
|
||||
import java.time.Instant
|
||||
|
||||
plugins {
|
||||
@@ -12,7 +10,8 @@ plugins {
|
||||
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("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.2.0" // Database migrations
|
||||
id("org.flywaydb.flyway") version "10.6.0" // Database migrations
|
||||
id("org.jooq.jooq-codegen-gradle") version "3.19.1"
|
||||
|
||||
eclipse
|
||||
idea
|
||||
@@ -46,7 +45,7 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
maven("https://repo.kryptonmc.org/releases/") {
|
||||
maven("https://repo.kryptonmc.org/releases") {
|
||||
content { includeGroup("me.neznamy") }
|
||||
}
|
||||
|
||||
@@ -63,7 +62,7 @@ dependencies {
|
||||
compileOnly("org.jetbrains:annotations:24.1.0")
|
||||
annotationProcessor("org.jetbrains:annotations:24.1.0")
|
||||
|
||||
paperweight.paperDevBundle("1.20.2-R0.1-SNAPSHOT")
|
||||
paperweight.paperDevBundle("1.20.4-R0.1-SNAPSHOT")
|
||||
implementation("space.arim.morepaperlib:morepaperlib:latest.release")
|
||||
|
||||
implementation("com.github.milkdrinkers:crate:1.1.0")
|
||||
@@ -80,7 +79,7 @@ dependencies {
|
||||
compileOnly("com.palmergames.bukkit.towny:towny:0.100.0.8") {
|
||||
exclude("com.palmergames.adventure")
|
||||
}
|
||||
compileOnly("me.neznamy:tab-api:4.0.0")
|
||||
compileOnly("me.neznamy:tab-api:4.0.2")
|
||||
compileOnly(files("lib/Graves-4.9.jar"))
|
||||
compileOnly("com.github.Gecolay.GSit:core:1.5.0")
|
||||
compileOnly(files("lib/HeadsPlus-7.0.14.jar"))
|
||||
@@ -88,16 +87,17 @@ dependencies {
|
||||
|
||||
// Database Dependencies
|
||||
implementation("com.zaxxer:HikariCP:5.1.0")
|
||||
library("org.flywaydb:flyway-core:10.2.0")
|
||||
library("org.flywaydb:flyway-mysql:10.2.0")
|
||||
library("org.flywaydb:flyway-database-hsqldb:10.2.0")
|
||||
library("org.jooq:jooq:3.19.0")
|
||||
library("org.flywaydb:flyway-core:10.6.0")
|
||||
library("org.flywaydb:flyway-mysql:10.6.0")
|
||||
library("org.flywaydb:flyway-database-hsqldb:10.6.0")
|
||||
library("org.jooq:jooq:3.19.1")
|
||||
jooqCodegen("com.h2database:h2:2.2.224")
|
||||
|
||||
// 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")
|
||||
library("com.mysql:mysql-connector-j:8.3.0")
|
||||
library("org.mariadb.jdbc:mariadb-java-client:3.3.2")
|
||||
}
|
||||
|
||||
tasks {
|
||||
@@ -116,9 +116,6 @@ tasks {
|
||||
// See https://openjdk.java.net/jeps/247 for more information.
|
||||
options.release.set(17)
|
||||
options.compilerArgs.addAll(arrayListOf("-Xlint:all", "-Xlint:-processing", "-Xdiags:verbose"))
|
||||
|
||||
// Generate jOOQ sources before compilation
|
||||
dependsOn(project.tasks.named("generateSources"))
|
||||
}
|
||||
|
||||
javadoc {
|
||||
@@ -163,7 +160,7 @@ tasks {
|
||||
url("https://ci.dmulloy2.net/job/ProtocolLib/lastStableBuild/artifact/build/libs/ProtocolLib.jar")
|
||||
github("MilkBowl", "Vault", "1.7.3", "Vault.jar")
|
||||
url("https://download.luckperms.net/1521/bukkit/loader/LuckPerms-Bukkit-5.4.108.jar")
|
||||
modrinth("tab-was-taken", "4.0.9")
|
||||
modrinth("tab-was-taken", "4.1.2")
|
||||
// url("https://www.spigotmc.org/resources/skulls-the-ultimate-head-database.90098/download?version=520217/Skulls.jar")
|
||||
}
|
||||
}
|
||||
@@ -210,49 +207,55 @@ flyway {
|
||||
)
|
||||
}
|
||||
|
||||
task("generateSources") {
|
||||
this.group = "jooq"
|
||||
val dir = layout.buildDirectory.dir("generated-src/jooq").get()
|
||||
jooq {
|
||||
configuration {
|
||||
logging = Logging.ERROR
|
||||
jdbc {
|
||||
driver = "org.h2.Driver"
|
||||
url = flyway.url
|
||||
user = flyway.user
|
||||
password = flyway.password
|
||||
}
|
||||
generator {
|
||||
database {
|
||||
name = "org.jooq.meta.h2.H2Database"
|
||||
includes = ".*"
|
||||
excludes = "(flyway_schema_history)|(?i:information_schema\\..*)|(?i:system_lobs\\..*)" // Exclude db specific files
|
||||
inputSchema = "PUBLIC"
|
||||
schemaVersionProvider = "SELECT :schema_name || '_' || MAX(\"version\") FROM \"flyway_schema_history\"" // Grab version from Flyway
|
||||
}
|
||||
target {
|
||||
packageName = "${mainPackage}.db.schema"
|
||||
directory = layout.buildDirectory.dir("generated-src/jooq").get().toString()
|
||||
withClean(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure database schema has been prepared by Flyway before generating the jOOQ sources
|
||||
dependsOn.add(tasks.flywayMigrate)
|
||||
tasks.withType<FlywayMigrateTask>().configureEach { // Declare Flyway migration scripts as inputs
|
||||
inputs.files(
|
||||
fileTree("src/main/resources/db/migration"),
|
||||
fileTree("src/main/java/${mainPackage}/db/flyway/migration")
|
||||
).withPropertyName("flyway-migration-files").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
|
||||
outputs.files(
|
||||
fileTree("${project.layout.buildDirectory.get()}/generated/flyway"),
|
||||
).withPropertyName("flyway-files")
|
||||
}
|
||||
|
||||
tasks.withType<CodegenTask>().configureEach {
|
||||
dependsOn.add(tasks.flywayMigrate) // Ensure database schema has been prepared by Flyway before generating the jOOQ sources
|
||||
|
||||
// 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)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
inputs.files(
|
||||
fileTree("src/main/resources/db/migration"),
|
||||
fileTree("src/main/java/${mainPackage}/db/flyway/migration")
|
||||
).withPropertyName("flyway-migration-files").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
|
||||
// Declare outputs
|
||||
outputs.dir(dir)
|
||||
.withPropertyName("jooq generated sources")
|
||||
val dir = layout.buildDirectory.dir("generated-src/jooq").get()
|
||||
outputs.dir(dir).withPropertyName("jooq-generated-sources")
|
||||
sourceSets {
|
||||
get("main").java.srcDir(dir)
|
||||
}
|
||||
@@ -261,15 +264,6 @@ task("generateSources") {
|
||||
outputs.cacheIf { true }
|
||||
}
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath("org.jooq:jooq:3.19.0")
|
||||
classpath("org.jooq:jooq-meta:3.19.0")
|
||||
classpath("org.jooq:jooq-codegen:3.19.0")
|
||||
classpath("com.h2database:h2:2.2.224")
|
||||
}
|
||||
}
|
||||
|
||||
// Apply custom version arg
|
||||
val versionArg = if (hasProperty("customVersion"))
|
||||
(properties["customVersion"] as String).uppercase() // Uppercase version string
|
||||
|
||||
Reference in new issue
Block a user