2021-10-31 12:16:47 +01:00
|
|
|
import dev.vankka.dependencydownload.task.GenerateDependencyDownloadResourceTask
|
2022-04-06 16:37:23 +02:00
|
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
2021-10-31 12:16:47 +01:00
|
|
|
|
|
|
|
plugins {
|
2022-02-28 17:50:21 +01:00
|
|
|
id "dev.vankka.dependencydownload.plugin" version "$dependencyDownloadVersion"
|
2024-02-17 08:23:25 +01:00
|
|
|
id "com.github.node-gradle.node" version "7.0.2"
|
2024-03-23 12:09:06 +01:00
|
|
|
id "io.swagger.core.v3.swagger-gradle-plugin" version "2.2.21"
|
2021-10-31 12:16:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
configurations {
|
2022-07-13 20:21:20 +02:00
|
|
|
// Runtime downloading scopes
|
2021-10-31 12:16:47 +01:00
|
|
|
mysqlDriver
|
2023-07-20 08:01:26 +02:00
|
|
|
mariadbDriver
|
2021-10-31 12:16:47 +01:00
|
|
|
sqliteDriver
|
2023-05-06 09:37:42 +02:00
|
|
|
ipAddressMatcher
|
2023-07-20 08:01:26 +02:00
|
|
|
testImplementation.extendsFrom mysqlDriver, mariadbDriver, sqliteDriver, ipAddressMatcher
|
|
|
|
compileOnly.extendsFrom mysqlDriver, mariadbDriver, sqliteDriver, ipAddressMatcher
|
2022-07-13 20:21:20 +02:00
|
|
|
|
2022-07-15 07:34:18 +02:00
|
|
|
swaggerJson // swagger.json configuration
|
2021-10-31 12:16:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
task generateResourceForMySQLDriver(type: GenerateDependencyDownloadResourceTask) {
|
|
|
|
var conf = configurations.mysqlDriver
|
|
|
|
configuration = conf
|
|
|
|
file = "assets/plan/dependencies/" + conf.name + ".txt"
|
|
|
|
// Not necessary to include in the resource
|
|
|
|
includeShadowJarRelocations = false
|
|
|
|
}
|
|
|
|
|
2023-07-20 08:01:26 +02:00
|
|
|
task generateResourceForMariaDBDriver(type: GenerateDependencyDownloadResourceTask) {
|
|
|
|
var conf = configurations.mariadbDriver
|
|
|
|
configuration = conf
|
|
|
|
file = "assets/plan/dependencies/" + conf.name + ".txt"
|
|
|
|
// Not necessary to include in the resource
|
|
|
|
includeShadowJarRelocations = false
|
|
|
|
}
|
|
|
|
|
2021-10-31 12:16:47 +01:00
|
|
|
task generateResourceForSQLiteDriver(type: GenerateDependencyDownloadResourceTask) {
|
|
|
|
var conf = configurations.sqliteDriver
|
|
|
|
configuration = conf
|
|
|
|
file = "assets/plan/dependencies/" + conf.name + ".txt"
|
|
|
|
// Not necessary to include in the resource
|
|
|
|
includeShadowJarRelocations = false
|
|
|
|
}
|
|
|
|
|
2023-05-06 09:37:42 +02:00
|
|
|
task generateResourceForIpAddressMatcher(type: GenerateDependencyDownloadResourceTask) {
|
|
|
|
var conf = configurations.ipAddressMatcher
|
|
|
|
configuration = conf
|
|
|
|
file = "assets/plan/dependencies/" + conf.name + ".txt"
|
|
|
|
// Not necessary to include in the resource
|
|
|
|
includeShadowJarRelocations = false
|
|
|
|
}
|
|
|
|
|
2018-12-18 20:13:05 +01:00
|
|
|
dependencies {
|
2021-06-12 07:24:24 +02:00
|
|
|
implementation project(":api")
|
2022-07-13 20:21:20 +02:00
|
|
|
shadow project(":extensions")
|
2021-10-31 12:16:47 +01:00
|
|
|
|
2022-07-13 20:21:20 +02:00
|
|
|
shadow "net.playeranalytics:platform-abstraction-layer-api:$palVersion"
|
2023-06-11 13:24:04 +02:00
|
|
|
compileOnly "net.kyori:adventure-api:4.14.0"
|
2022-07-13 20:21:20 +02:00
|
|
|
shadow("dev.vankka:dependencydownload-runtime:$dependencyDownloadVersion") {
|
2021-10-31 12:16:47 +01:00
|
|
|
// Effectively disables relocating
|
|
|
|
exclude module: "jar-relocator"
|
|
|
|
}
|
2023-07-20 08:01:26 +02:00
|
|
|
mysqlDriver "com.mysql:mysql-connector-j:$mysqlVersion"
|
|
|
|
mariadbDriver "org.mariadb.jdbc:mariadb-java-client:$mariadbVersion"
|
2021-10-31 12:16:47 +01:00
|
|
|
sqliteDriver "org.xerial:sqlite-jdbc:$sqliteVersion"
|
2024-01-28 11:34:24 +01:00
|
|
|
sqliteDriver "org.slf4j:slf4j-nop:1.7.36"
|
2023-05-06 09:37:42 +02:00
|
|
|
ipAddressMatcher "com.github.seancfoley:ipaddress:$ipAddressMatcherVersion"
|
2022-07-13 20:21:20 +02:00
|
|
|
|
|
|
|
shadow "org.apache.commons:commons-text:$commonsTextVersion"
|
|
|
|
shadow "org.apache.commons:commons-compress:$commonsCompressVersion"
|
|
|
|
shadow "commons-codec:commons-codec:$commonsCodecVersion"
|
|
|
|
shadow "com.github.ben-manes.caffeine:caffeine:$caffeineVersion"
|
|
|
|
shadow "com.zaxxer:HikariCP:$hikariVersion"
|
|
|
|
shadow "org.slf4j:slf4j-nop:$slf4jVersion"
|
|
|
|
shadow "org.slf4j:slf4j-api:$slf4jVersion"
|
|
|
|
shadow "com.maxmind.geoip2:geoip2:$geoIpVersion"
|
|
|
|
shadow "com.google.code.gson:gson:$gsonVersion"
|
|
|
|
shadow "org.eclipse.jetty:jetty-server:$jettyVersion"
|
|
|
|
shadow "org.eclipse.jetty:jetty-alpn-java-server:$jettyVersion"
|
|
|
|
shadow "org.eclipse.jetty.http2:http2-server:$jettyVersion"
|
2022-10-30 11:02:29 +01:00
|
|
|
shadow("com.googlecode.json-simple:json-simple:1.1.1") { // json simple used by UUIDFetcher
|
|
|
|
// json-simple has junit (a test dependency) compile scoped
|
|
|
|
exclude group: "junit", module: "junit"
|
|
|
|
}
|
2023-10-15 11:52:28 +02:00
|
|
|
implementation "org.jasypt:jasypt:$jasyptVersion:lite"
|
|
|
|
|
2022-07-13 20:21:20 +02:00
|
|
|
|
|
|
|
// Swagger annotations
|
|
|
|
implementation "jakarta.ws.rs:jakarta.ws.rs-api:3.1.0"
|
|
|
|
implementation "io.swagger.core.v3:swagger-core-jakarta:$swaggerVersion"
|
|
|
|
implementation "io.swagger.core.v3:swagger-jaxrs2-jakarta:$swaggerVersion"
|
2019-03-20 16:17:23 +01:00
|
|
|
|
2021-06-12 07:24:24 +02:00
|
|
|
testImplementation project(":api")
|
2022-10-16 12:21:49 +02:00
|
|
|
testArtifacts project(":extensions:adventure")
|
|
|
|
testImplementation project(":extensions:adventure")
|
2021-06-12 07:24:24 +02:00
|
|
|
testImplementation "com.google.code.gson:gson:$gsonVersion"
|
2024-04-05 13:34:01 +02:00
|
|
|
testImplementation "org.seleniumhq.selenium:selenium-java:4.19.1"
|
2022-02-27 14:40:35 +01:00
|
|
|
testImplementation "org.testcontainers:testcontainers:$testContainersVersion"
|
|
|
|
testImplementation "org.testcontainers:junit-jupiter:$testContainersVersion"
|
|
|
|
testImplementation "org.testcontainers:nginx:$testContainersVersion"
|
2018-12-18 20:13:05 +01:00
|
|
|
}
|
|
|
|
|
2019-12-07 19:12:45 +01:00
|
|
|
task updateVersion(type: Copy) {
|
|
|
|
from('src/main/resources') {
|
|
|
|
include 'plugin.yml'
|
|
|
|
include 'bungee.yml'
|
2019-12-08 09:26:24 +01:00
|
|
|
include 'nukkit.yml'
|
2021-07-24 13:10:48 +02:00
|
|
|
include 'fabric.mod.json'
|
2019-12-07 19:12:45 +01:00
|
|
|
}
|
|
|
|
into 'build/sources/resources/'
|
|
|
|
filter(ReplaceTokens, tokens: [version: '' + project.ext.fullVersion])
|
|
|
|
}
|
2021-07-23 16:17:35 +02:00
|
|
|
|
2022-04-06 16:37:23 +02:00
|
|
|
node {
|
2022-04-15 10:07:32 +02:00
|
|
|
download = true
|
2023-12-10 08:29:01 +01:00
|
|
|
version = "20.9.0"
|
2022-04-06 16:37:23 +02:00
|
|
|
nodeProjectDir = file("$rootDir/react/dashboard")
|
|
|
|
}
|
|
|
|
|
|
|
|
task yarnBundle(type: YarnTask) {
|
|
|
|
inputs.files(fileTree("$rootDir/react/dashboard/src"))
|
|
|
|
inputs.file("$rootDir/react/dashboard/package.json")
|
2023-12-10 08:29:01 +01:00
|
|
|
inputs.file("$rootDir/react/dashboard/vite.config.js")
|
2022-04-06 16:37:23 +02:00
|
|
|
|
|
|
|
outputs.dir("$rootDir/react/dashboard/build")
|
|
|
|
|
|
|
|
dependsOn yarn_install
|
|
|
|
args = ['run', 'build']
|
|
|
|
}
|
|
|
|
|
2023-02-05 11:08:29 +01:00
|
|
|
task yarnStart(type: YarnTask) {
|
|
|
|
logging.captureStandardOutput LogLevel.INFO
|
|
|
|
inputs.file("$rootDir/react/dashboard/package.json")
|
|
|
|
|
|
|
|
dependsOn yarn_install
|
|
|
|
args = ['run', 'start']
|
|
|
|
}
|
|
|
|
|
2022-04-06 16:37:23 +02:00
|
|
|
task copyYarnBuildResults {
|
|
|
|
inputs.files(fileTree("$rootDir/react/dashboard/build"))
|
|
|
|
outputs.dir("$rootDir/common/build/resources/main/assets/plan/web")
|
2023-09-23 21:24:34 +02:00
|
|
|
outputs.dir("$rootDir/common/build/resources/test/assets/plan/web")
|
2022-04-06 16:37:23 +02:00
|
|
|
|
|
|
|
dependsOn yarnBundle
|
|
|
|
doLast {
|
|
|
|
mkdir "$rootDir/common/build/resources/main/assets/plan/web"
|
|
|
|
copy {
|
|
|
|
from "$rootDir/react/dashboard/build"
|
|
|
|
into "$rootDir/common/build/resources/main/assets/plan/web"
|
|
|
|
}
|
2023-09-23 21:24:34 +02:00
|
|
|
copy {
|
|
|
|
into "$rootDir/common/build/resources/main/assets/plan/web"
|
|
|
|
into "$rootDir/common/build/resources/test/assets/plan/web"
|
|
|
|
}
|
2022-04-06 16:37:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-28 09:21:46 +02:00
|
|
|
task determineAssetModifications {
|
2022-11-26 08:01:33 +01:00
|
|
|
dependsOn yarnBundle
|
|
|
|
inputs.files(fileTree("$rootDir/react/dashboard/build"))
|
2022-08-28 09:21:46 +02:00
|
|
|
inputs.files(fileTree(dir: 'src/main/resources/assets/plan/web'))
|
|
|
|
inputs.files(fileTree(dir: 'src/main/resources/assets/plan/locale'))
|
|
|
|
outputs.file("build/resources/main/assets/plan/AssetVersion.yml")
|
|
|
|
|
2021-07-24 08:09:05 +02:00
|
|
|
doLast {
|
|
|
|
mkdir "build/resources/main/assets/plan"
|
2022-08-28 09:21:46 +02:00
|
|
|
def versionFile = file("build/resources/main/assets/plan/AssetVersion.yml")
|
2021-07-24 08:09:05 +02:00
|
|
|
versionFile.text = "" // Clear previous build
|
|
|
|
ConfigurableFileTree tree = fileTree(dir: 'src/main/resources/assets/plan/web')
|
|
|
|
tree.forEach { File f ->
|
|
|
|
def gitModified = new ByteArrayOutputStream()
|
|
|
|
exec {
|
|
|
|
commandLine 'git', 'log', '-1', '--pretty=%ct', f.toString()
|
|
|
|
standardOutput = gitModified
|
|
|
|
}
|
2021-09-26 13:00:54 +02:00
|
|
|
def gitModifiedAsString = gitModified.toString().strip()
|
2021-07-24 08:09:05 +02:00
|
|
|
// git returns UNIX time in seconds, but most things in Java use UNIX time in milliseconds
|
2021-09-26 13:00:54 +02:00
|
|
|
def modified = gitModifiedAsString.isEmpty() ? System.currentTimeMillis() : Long.parseLong(gitModifiedAsString) * 1000
|
2021-07-24 08:09:05 +02:00
|
|
|
def relativePath = tree.getDir().toPath().relativize(f.toPath()) // File path relative to the tree
|
2022-11-26 08:01:33 +01:00
|
|
|
versionFile.text += String.format(
|
2022-11-27 08:48:55 +01:00
|
|
|
"%s: %s\n", relativePath.toString().replace('.', ',').replace('\\', '/'), modified
|
2021-07-24 08:09:05 +02:00
|
|
|
)
|
2021-07-23 16:17:35 +02:00
|
|
|
}
|
2022-08-28 09:21:46 +02:00
|
|
|
tree = fileTree(dir: 'src/main/resources/assets/plan/locale')
|
|
|
|
tree.forEach { File f ->
|
|
|
|
def gitModified = new ByteArrayOutputStream()
|
|
|
|
exec {
|
|
|
|
commandLine 'git', 'log', '-1', '--pretty=%ct', f.toString()
|
|
|
|
standardOutput = gitModified
|
|
|
|
}
|
|
|
|
def gitModifiedAsString = gitModified.toString().strip()
|
|
|
|
// git returns UNIX time in seconds, but most things in Java use UNIX time in milliseconds
|
|
|
|
def modified = gitModifiedAsString.isEmpty() ? System.currentTimeMillis() : Long.parseLong(gitModifiedAsString) * 1000
|
|
|
|
def relativePath = tree.getDir().toPath().relativize(f.toPath()) // File path relative to the tree
|
2022-11-26 08:01:33 +01:00
|
|
|
versionFile.text += String.format(
|
2022-11-27 08:48:55 +01:00
|
|
|
"%s: %s\n", relativePath.toString().replace('.', ',').replace('\\', '/'), modified
|
2022-11-26 08:01:33 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
tree = fileTree("$rootDir/react/dashboard/build")
|
|
|
|
tree.forEach { File f ->
|
2022-11-27 08:48:55 +01:00
|
|
|
if (f.getName().endsWith(".map")) return
|
2022-11-26 08:01:33 +01:00
|
|
|
def modified = System.currentTimeMillis()
|
|
|
|
def relativePath = tree.getDir().toPath().relativize(f.toPath()) // File path relative to the tree
|
|
|
|
versionFile.text += String.format(
|
2022-11-27 08:48:55 +01:00
|
|
|
"%s: %s\n", relativePath.toString().replace('.', ',').replace('\\', '/'), modified
|
2022-08-28 09:21:46 +02:00
|
|
|
)
|
|
|
|
}
|
2021-07-23 16:17:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-13 20:21:20 +02:00
|
|
|
resolve { // Swagger json generation task
|
|
|
|
outputFileName = 'swagger'
|
|
|
|
outputFormat = 'JSON'
|
|
|
|
prettyPrint = 'TRUE'
|
|
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
|
|
buildClasspath = classpath
|
|
|
|
resourcePackages = [
|
|
|
|
'com.djrapitops.plan.delivery.webserver',
|
|
|
|
'com.djrapitops.plan.delivery.webserver.resolver.auth',
|
|
|
|
'com.djrapitops.plan.delivery.webserver.resolver.json',
|
|
|
|
]
|
|
|
|
outputDir = file('build/generated-resources/swagger/assets/plan/web/')
|
|
|
|
}
|
|
|
|
task swaggerJsonJar(type: Jar) {
|
|
|
|
dependsOn resolve
|
|
|
|
archiveClassifier.set("resolve")
|
|
|
|
from 'build/generated-resources/swagger'
|
|
|
|
}
|
|
|
|
artifacts {
|
|
|
|
swaggerJson swaggerJsonJar
|
|
|
|
}
|
|
|
|
|
2019-12-07 19:12:45 +01:00
|
|
|
processResources {
|
2024-03-09 09:29:44 +01:00
|
|
|
// Skips Yarn build on Jitpack since Jitpack doesn't offer gclib version compatible with Node 20
|
|
|
|
// Jitpack build is used mainly for java dependencies.
|
|
|
|
if (!project.hasProperty("isJitpack")) {
|
|
|
|
dependsOn copyYarnBuildResults
|
|
|
|
dependsOn determineAssetModifications
|
|
|
|
}
|
2022-07-13 20:21:20 +02:00
|
|
|
dependsOn generateResourceForMySQLDriver
|
|
|
|
dependsOn generateResourceForSQLiteDriver
|
2023-05-06 09:37:42 +02:00
|
|
|
dependsOn generateResourceForIpAddressMatcher
|
2019-12-07 19:12:45 +01:00
|
|
|
dependsOn updateVersion
|
2022-07-13 20:21:20 +02:00
|
|
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
2019-12-07 19:12:45 +01:00
|
|
|
from 'build/sources/resources'
|
|
|
|
}
|
|
|
|
|
2018-12-18 20:13:05 +01:00
|
|
|
shadowJar {
|
2022-07-13 20:21:20 +02:00
|
|
|
configurations = [project.configurations.shadow]
|
2021-10-31 12:16:47 +01:00
|
|
|
}
|