Velocitab/build.gradle
AlexDev_ fc39861f33
refactor: Make MiniMessage the default formatter, fix bugs (#208)
* Fixed some problems
Changed default formatter to MINIMESAGE

* Removed debug message
2024-08-11 13:31:56 +01:00

192 lines
6.3 KiB
Groovy

import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'xyz.jpenilla.run-velocity' version '2.3.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'org.cadixdev.licenser' version '0.6.1'
id 'org.ajoberstar.grgit' version '5.2.2'
id 'maven-publish'
id 'java'
}
group 'net.william278'
version "$ext.plugin_version${versionMetadata()}"
description "$ext.plugin_description"
defaultTasks 'licenseFormat', 'build'
ext {
set 'version', version.toString()
set 'description', description.toString()
set 'velocity_api_version', velocity_api_version.toString()
set 'velocity_minimum_build', velocity_minimum_build.toString()
}
repositories {
mavenCentral()
maven { url = 'https://repo.william278.net/velocity/' }
maven { url = 'https://repo.papermc.io/repository/maven-public/' }
maven { url = 'https://repo.william278.net/releases/' }
maven { url = 'https://repo.william278.net/snapshots/' }
maven { url = 'https://jitpack.io/' }
maven { url = 'https://repo.minebench.de/' }
}
dependencies {
compileOnly "com.velocitypowered:velocity-api:${velocity_api_version}-SNAPSHOT"
compileOnly "com.velocitypowered:velocity-proxy:${velocity_api_version}-SNAPSHOT"
compileOnly 'io.netty:netty-codec-http:4.1.112.Final'
compileOnly 'org.projectlombok:lombok:1.18.34'
compileOnly 'net.luckperms:api:5.4'
compileOnly 'io.github.miniplaceholders:miniplaceholders-api:2.2.3'
compileOnly 'net.william278:PAPIProxyBridge:1.5'
compileOnly 'it.unimi.dsi:fastutil:8.5.14'
compileOnly 'net.kyori:adventure-nbt:4.17.0'
implementation 'org.apache.commons:commons-text:1.12.0'
implementation 'net.william278:DesertWell:2.0.4'
implementation 'net.william278:minedown:1.8.2'
implementation 'org.bstats:bstats-velocity:3.0.2'
implementation 'de.exlll:configlib-yaml:4.5.0'
implementation 'org.apache.commons:commons-jexl3:3.4.0'
implementation 'net.jodah:expiringmap:0.5.11'
implementation("net.william278:velocityscoreboardapi:1.0.0-b2d9518")
annotationProcessor 'org.projectlombok:lombok:1.18.34'
}
processResources {
def tokenMap = rootProject.ext.properties
tokenMap.merge("grgit",'',(s, s2) -> s)
filesMatching(['**/*.json', '**/*.yml']) {
filter ReplaceTokens as Class, beginToken: '${', endToken: '}',
tokens: tokenMap
}
}
license {
header = rootProject.file('HEADER')
include '**/*.java'
newLine = true
}
logger.lifecycle("Building Velocitab ${version} by William278")
version rootProject.version
archivesBaseName = "${rootProject.name}"
compileJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
java {
def javaVersion = JavaVersion.toVersion(javaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
withSourcesJar()
withJavadocJar()
}
shadowJar {
relocate 'org.apache.commons.text', 'net.william278.velocitab.libraries.commons.text'
relocate 'org.apache.commons.lang3', 'net.william278.velocitab.libraries.commons.lang3'
relocate 'org.jetbrains', 'net.william278.velocitab.libraries'
relocate 'org.intellij', 'net.william278.velocitab.libraries'
relocate 'de.themoep', 'net.william278.velocitab.libraries'
relocate 'net.william278.annotaml', 'net.william278.velocitab.libraries.annotaml'
relocate 'net.william278.desertwell', 'net.william278.velocitab.libraries.desertwell'
relocate 'org.bstats', 'net.william278.velocitab.libraries.bstats'
relocate 'de.exlll.configlib', 'net.william278.velocitab.libraries.configlib'
relocate 'org.snakeyaml', 'net.william278.velocitab.libraries.snakeyaml'
relocate 'org.apache.commons.jexl3', 'net.william278.velocitab.libraries.commons.jexl3'
relocate 'org.apache.commons.logging', 'net.william278.velocitab.libraries.commons.logging'
relocate 'net.jodah.expiringmap', 'net.william278.velocitab.libraries.expiringmap'
dependencies {
exclude dependency(':slf4j-api')
exclude dependency('org.json:json')
}
destinationDirectory.set(file("$rootDir/target"))
archiveClassifier.set('')
minimize() {
exclude dependency('commons-logging:commons-logging')
}
}
jar.dependsOn shadowJar
clean.delete "$rootDir/target"
publishing {
repositories {
if (System.getenv("RELEASES_MAVEN_USERNAME") != null) {
maven {
name = "william278-releases"
url = "https://repo.william278.net/releases"
credentials {
username = System.getenv("RELEASES_MAVEN_USERNAME")
password = System.getenv("RELEASES_MAVEN_PASSWORD")
}
authentication {
basic(BasicAuthentication)
}
}
}
if (System.getenv("SNAPSHOTS_MAVEN_USERNAME") != null) {
maven {
name = "william278-snapshots"
url = "https://repo.william278.net/snapshots"
credentials {
username = System.getenv("SNAPSHOTS_MAVEN_USERNAME")
password = System.getenv("SNAPSHOTS_MAVEN_PASSWORD")
}
authentication {
basic(BasicAuthentication)
}
}
}
}
publications {
mavenJava(MavenPublication) {
groupId = 'net.william278'
artifactId = 'velocitab'
version = "$rootProject.version"
artifact shadowJar
artifact javadocJar
artifact sourcesJar
}
}
}
tasks {
runVelocity {
velocityVersion("${velocity_api_version}-SNAPSHOT")
downloadPlugins {
modrinth ("papiproxybridge", "1.6.1")
modrinth ("miniplaceholders", "2.2.4")
}
}
}
@SuppressWarnings('GrMethodMayBeStatic')
def versionMetadata() {
// Require grgit
if (grgit == null) {
return '-unknown'
}
// If unclean, return the last commit hash with -indev
if (!grgit.status().clean) {
return '-' + grgit.head().abbreviatedId + '-indev'
}
// Otherwise if this matches a tag, return nothing
def tag = grgit.tag.list().find { it.commit.id == grgit.head().id }
if (tag != null) {
return ''
}
return '-' + grgit.head().abbreviatedId
}