Files
TCPShield/build.gradle
T
2025-06-01 16:01:00 -04:00

155 lines
3.6 KiB
Groovy

import com.google.gson.JsonObject
import com.google.gson.JsonParser
import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.Yaml
import java.nio.charset.StandardCharsets
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath(group: 'org.yaml', name: 'snakeyaml', version: '1.26')
classpath(group: 'com.google.code.gson', name: 'gson', version: '2.8.6')
}
}
plugins {
id 'java'
id 'eclipse'
id 'idea'
}
version = '2.8.0'
group = 'net.tcpshield.tcpshield'
base {
archivesName = 'TCPShield'
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
sourceSets {
main {
java {
srcDirs('src/main/java')
}
resources {
srcDirs('src/main/resources')
}
}
test {
java {
srcDirs('src/test/java')
}
resources {
srcDirs('src/test/resources')
}
}
}
compileJava {
sourceCompatibility = 17
targetCompatibility = 17
options.encoding = 'UTF-8'
}
repositories {
maven {
url = 'https://repo1.maven.org/maven2/'
}
maven {
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
url = 'https://repo.dmulloy2.net/nexus/repository/public/'
}
maven {
url = 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven {
url = 'https://repo.papermc.io/repository/maven-public/'
}
maven {
url = 'https://repo.opencollab.dev/maven-snapshots/'
}
}
dependencies {
compileOnly 'com.comphenix.protocol:ProtocolLib:5.1.0'
compileOnly 'io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT'
compileOnly 'net.md-5:bungeecord-api:1.14-SNAPSHOT'
compileOnly 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0-M1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0-M1'
compileOnly 'org.geysermc.floodgate:api:2.1.1-SNAPSHOT'
}
processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
test {
useJUnitPlatform()
}
configurations {
testImplementation.extendsFrom compileOnly
}
task updateVersion {
updateYamls()
updateJsons()
}
void updateYamls() {
DumperOptions options = new DumperOptions()
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK)
options.setSplitLines(false)
options.setPrettyFlow(true)
def yaml = new Yaml(options)
def bukkitYamlFile = new File('src/main/resources/plugin.yml')
def bungeeYamlFile = new File('src/main/resources/bungee.yml')
def files = [bukkitYamlFile, bungeeYamlFile]
files.each { file ->
file.newInputStream().withCloseable { inputStream ->
def cfg = yaml.load(inputStream)
cfg.put("version", version)
new FileWriter(file).withCloseable { writer ->
yaml.dump(cfg, writer)
}
}
}
}
void updateJsons() {
def velocityJson = new File('src/main/resources/velocity-plugin.json')
def files = [velocityJson]
files.each { file ->
file.newInputStream().withCloseable { inputStream ->
new InputStreamReader(inputStream, StandardCharsets.UTF_8).withCloseable { inputStreamReader ->
JsonObject object = JsonParser.parseReader(inputStreamReader).getAsJsonObject()
object.addProperty("version", version.toString())
new FileWriter(file).withCloseable { writer ->
writer.write(object.toString())
}
}
}
}
}
build.dependsOn updateVersion