mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-03 14:38:56 +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.flywaydb.gradle.task.FlywayMigrateTask
|
||||||
import org.jooq.meta.jaxb.Configuration
|
import org.jooq.codegen.gradle.CodegenTask
|
||||||
import org.jooq.meta.jaxb.Database
|
import org.jooq.meta.jaxb.Logging
|
||||||
import org.jooq.meta.jaxb.Generator
|
|
||||||
import org.jooq.meta.jaxb.Jdbc
|
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
@@ -12,7 +10,8 @@ plugins {
|
|||||||
id("xyz.jpenilla.run-paper") version "2.2.2" // 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.9" // Used to develop internal plugins using Mojang mappings, See https://github.com/PaperMC/paperweight
|
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
|
eclipse
|
||||||
idea
|
idea
|
||||||
@@ -46,7 +45,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
maven("https://repo.kryptonmc.org/releases/") {
|
maven("https://repo.kryptonmc.org/releases") {
|
||||||
content { includeGroup("me.neznamy") }
|
content { includeGroup("me.neznamy") }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ dependencies {
|
|||||||
compileOnly("org.jetbrains:annotations:24.1.0")
|
compileOnly("org.jetbrains:annotations:24.1.0")
|
||||||
annotationProcessor("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("space.arim.morepaperlib:morepaperlib:latest.release")
|
||||||
|
|
||||||
implementation("com.github.milkdrinkers:crate:1.1.0")
|
implementation("com.github.milkdrinkers:crate:1.1.0")
|
||||||
@@ -80,7 +79,7 @@ dependencies {
|
|||||||
compileOnly("com.palmergames.bukkit.towny:towny:0.100.0.8") {
|
compileOnly("com.palmergames.bukkit.towny:towny:0.100.0.8") {
|
||||||
exclude("com.palmergames.adventure")
|
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(files("lib/Graves-4.9.jar"))
|
||||||
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"))
|
||||||
@@ -88,16 +87,17 @@ dependencies {
|
|||||||
|
|
||||||
// Database Dependencies
|
// Database Dependencies
|
||||||
implementation("com.zaxxer:HikariCP:5.1.0")
|
implementation("com.zaxxer:HikariCP:5.1.0")
|
||||||
library("org.flywaydb:flyway-core:10.2.0")
|
library("org.flywaydb:flyway-core:10.6.0")
|
||||||
library("org.flywaydb:flyway-mysql:10.2.0")
|
library("org.flywaydb:flyway-mysql:10.6.0")
|
||||||
library("org.flywaydb:flyway-database-hsqldb:10.2.0")
|
library("org.flywaydb:flyway-database-hsqldb:10.6.0")
|
||||||
library("org.jooq:jooq:3.19.0")
|
library("org.jooq:jooq:3.19.1")
|
||||||
|
jooqCodegen("com.h2database:h2:2.2.224")
|
||||||
|
|
||||||
// JDBC Drivers
|
// JDBC Drivers
|
||||||
library("org.hsqldb:hsqldb:2.7.2")
|
library("org.hsqldb:hsqldb:2.7.2")
|
||||||
library("com.h2database:h2:2.2.224")
|
library("com.h2database:h2:2.2.224")
|
||||||
library("com.mysql:mysql-connector-j:8.2.0")
|
library("com.mysql:mysql-connector-j:8.3.0")
|
||||||
library("org.mariadb.jdbc:mariadb-java-client:3.3.0")
|
library("org.mariadb.jdbc:mariadb-java-client:3.3.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
@@ -116,9 +116,6 @@ 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 {
|
javadoc {
|
||||||
@@ -163,7 +160,7 @@ tasks {
|
|||||||
url("https://ci.dmulloy2.net/job/ProtocolLib/lastStableBuild/artifact/build/libs/ProtocolLib.jar")
|
url("https://ci.dmulloy2.net/job/ProtocolLib/lastStableBuild/artifact/build/libs/ProtocolLib.jar")
|
||||||
github("MilkBowl", "Vault", "1.7.3", "Vault.jar")
|
github("MilkBowl", "Vault", "1.7.3", "Vault.jar")
|
||||||
url("https://download.luckperms.net/1521/bukkit/loader/LuckPerms-Bukkit-5.4.108.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")
|
// url("https://www.spigotmc.org/resources/skulls-the-ultimate-head-database.90098/download?version=520217/Skulls.jar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,49 +207,55 @@ flyway {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
task("generateSources") {
|
jooq {
|
||||||
this.group = "jooq"
|
configuration {
|
||||||
val dir = layout.buildDirectory.dir("generated-src/jooq").get()
|
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
|
tasks.withType<FlywayMigrateTask>().configureEach { // Declare Flyway migration scripts as inputs
|
||||||
dependsOn.add(tasks.flywayMigrate)
|
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
|
// 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"))
|
inputs.files(
|
||||||
.withPropertyName("migration files")
|
fileTree("src/main/resources/db/migration"),
|
||||||
.withPathSensitivity(PathSensitivity.RELATIVE)
|
fileTree("src/main/java/${mainPackage}/db/flyway/migration")
|
||||||
|
).withPropertyName("flyway-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
|
// Declare outputs
|
||||||
outputs.dir(dir)
|
val dir = layout.buildDirectory.dir("generated-src/jooq").get()
|
||||||
.withPropertyName("jooq generated sources")
|
outputs.dir(dir).withPropertyName("jooq-generated-sources")
|
||||||
sourceSets {
|
sourceSets {
|
||||||
get("main").java.srcDir(dir)
|
get("main").java.srcDir(dir)
|
||||||
}
|
}
|
||||||
@@ -261,15 +264,6 @@ task("generateSources") {
|
|||||||
outputs.cacheIf { true }
|
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
|
// 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
|
||||||
|
|||||||
Reference in new issue
Block a user