Add ProGuard obfuscation build task
Configures a JavaExec ProGuard task that runs after jar, keeping all plugin entry points and command/listener classes while repackaging into the mdbd package.
This commit is contained in:
parent
d0ed8a5fe7
commit
327ad9b906
1 changed files with 38 additions and 3 deletions
|
|
@ -9,15 +9,49 @@ repositories {
|
||||||
maven("https://repo.dmulloy2.net/repository/public/")
|
maven("https://repo.dmulloy2.net/repository/public/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val proguardConfig by configurations.creating
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.3.0")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.3.0")
|
||||||
|
proguardConfig("com.guardsquare:proguard-base:7.4.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion = JavaLanguageVersion.of(21)
|
toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val obfuscateTask = tasks.register<JavaExec>("obfuscate") {
|
||||||
|
description = "Obfuscate the plugin jar using ProGuard"
|
||||||
|
mainClass.set("proguard.ProGuard")
|
||||||
|
classpath = proguardConfig
|
||||||
|
|
||||||
|
val inJar = tasks.named<Jar>("jar").get().archiveFile.get().asFile.path
|
||||||
|
val outJar = layout.buildDirectory.file("libs/${project.name}-${version}-obf.jar").get().asFile.path
|
||||||
|
|
||||||
|
args(
|
||||||
|
"-injars", inJar,
|
||||||
|
"-outjars", outJar,
|
||||||
|
"-dontwarn",
|
||||||
|
"-ignorewarnings",
|
||||||
|
|
||||||
|
"-keep", "class dev.loki.mdbd",
|
||||||
|
"-keep", "class dev.loki.mdbdBootstrap",
|
||||||
|
"-keep", "class dev.loki.mdbdLoader",
|
||||||
|
"-keep", "class dev.loki.command.**",
|
||||||
|
"-keep", "class dev.loki.listener.**",
|
||||||
|
"-keepclassmembers", "class * { @org.bukkit.event.EventHandler *; }",
|
||||||
|
"-keepnames", "class dev.loki.**",
|
||||||
|
|
||||||
|
"-dontoptimize",
|
||||||
|
"-allowaccessmodification",
|
||||||
|
"-repackageclasses", "mdbd",
|
||||||
|
"-keepattributes", "Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,EnclosingMethod"
|
||||||
|
)
|
||||||
|
|
||||||
|
dependsOn(tasks.named("jar"))
|
||||||
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.21.1")
|
minecraftVersion("1.21.1")
|
||||||
|
|
@ -26,11 +60,12 @@ tasks {
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
val props = mapOf("version" to version)
|
val props = mapOf("version" to version)
|
||||||
filesMatching("paper-plugin.yml") {
|
|
||||||
expand(props)
|
|
||||||
}
|
|
||||||
filesMatching("*.yml") {
|
filesMatching("*.yml") {
|
||||||
expand(props)
|
expand(props)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
named("build") {
|
||||||
|
dependsOn(obfuscateTask)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue