perf: 优化代码

This commit is contained in:
2023-06-14 20:22:01 +08:00
parent 31510cf599
commit 57357c6ae2
5 changed files with 60 additions and 121 deletions

View File

@@ -1,93 +1,62 @@
//file:noinspection GroovyAssignabilityCheck
//file:noinspection VulnerableLibrariesLocal
//file:noinspection GrDeprecatedAPIUsage
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.johnrengelman.shadow' version '7+'
}
setArchivesBaseName("HamsterCore-Bukkit")
evaluationDependsOn(':hamster-core-common')
configurations {
oldJar
}
dependencies {
implementation "de.tr7zw:item-nbt-api:2.11.2"
//noinspection VulnerableLibrariesLocal
compileOnly 'org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT' exclude group: "com.google.code.gson"
compileOnly 'org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT'
compileOnly 'net.milkbowl.vault:VaultAPI:1.7' transitive false
compileOnly 'org.black_ixx:playerpoints:2.1.3' transitive false
api project(":hamster-core-common") transitive false
// https://mvnrepository.com/artifact/net.kyori/adventure-platform-bukkit
api "net.kyori:adventure-platform-bukkit:${adventure_version}"
// https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage
api "net.kyori:adventure-text-minimessage:${adventure_serializer_version}"
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-gson
api "net.kyori:adventure-text-serializer-gson:${adventure_serializer_version}"
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-legacy
api "net.kyori:adventure-text-serializer-legacy:${adventure_serializer_version}"
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP
compileOnly "com.zaxxer:HikariCP:${HikariCP_version}"
implementation project(":hamster-core-common") transitive false
//noinspection GradlePackageUpdate
oldJar 'com.zaxxer:HikariCP:4.0.3'
implementation "com.zaxxer:HikariCP:${HikariCP_version}"
//noinspection VulnerableLibrariesLocal
oldJar "net.kyori:adventure-platform-bukkit:${adventure_version}"
implementation "net.kyori:adventure-platform-bukkit:${adventure_version}" exclude group: 'org.jetbrains'
// https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage
implementation "net.kyori:adventure-text-minimessage:${adventure_serializer_version}" exclude group: 'org.jetbrains'
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-gson
implementation "net.kyori:adventure-text-serializer-gson:${adventure_serializer_version}" exclude group: 'org.jetbrains'
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-legacy
implementation "net.kyori:adventure-text-serializer-legacy:${adventure_serializer_version}" exclude group: 'org.jetbrains'
implementation "de.tr7zw:item-nbt-api:2.11.2"
}
processResources {
inputs.property "version", project.version
filesMatching("plugin.yml") {
expand "version": project.version,
"adventure_version": adventure_version,
"adventure_serializer_version": adventure_serializer_version,
"HikariCP_version": HikariCP_version
expand "version": project.version
}
}
jar {
//noinspection GrDeprecatedAPIUsage
classifier = "jar"
classifier = 'dev'
}
tasks.compileJava.dependsOn(":hamster-core-common:build")
shadowJar {
//noinspection GrDeprecatedAPIUsage
classifier = ""
classifier = ''
dependencies {
exclude(dependency {
it.moduleGroup != 'cn.hamster3.mc.plugin.core' && it.moduleGroup != 'de.tr7zw'
it.moduleGroup == 'com.google.code.gson' || it.moduleName == 'org.jetbrains'
})
}
relocate 'de.tr7zw.changeme.nbtapi', 'cn.hamster3.mc.plugin.core.bukkit.nbtapi'
relocate 'de.tr7zw.annotations', 'cn.hamster3.mc.plugin.core.bukkit.nbtapi.annotations'
relocate 'org.slf4j', 'cn.hamster3.mc.plugin.core.lib.slf4j'
relocate 'net.kyori', 'cn.hamster3.mc.plugin.core.lib.kyori'
relocate 'com.zaxxer.hikari', 'cn.hamster3.mc.plugin.core.lib.hikari'
relocate 'de.tr7zw.changeme.nbtapi', 'cn.hamster3.mc.plugin.core.lib.nbtapi'
relocate 'de.tr7zw.annotations', 'cn.hamster3.mc.plugin.core.lib.nbtapi.annotations'
destinationDir(getRootProject().buildDir)
}
tasks.build.dependsOn(shadowJar)
tasks.register("oldJar", Jar) {
dependsOn("jar")
//noinspection GrDeprecatedAPIUsage
setClassifier("Old")
from([
tasks.jar.outputs.files.collect {
it.isDirectory() ? it : zipTree(it)
},
configurations.shade.collect {
it.isDirectory() ? it : zipTree(it)
},
configurations.oldJar.collect {
it.isDirectory() ? it : zipTree(it)
}
])
destinationDir(getRootProject().buildDir)
}
tasks.build.dependsOn(oldJar)
publishing {
publications {
shadow(MavenPublication) { publication ->