@@ -21,6 +21,8 @@ dependencies {
2121 implementation(libs.kaml)
2222 implementation(libs.jbcrypt)
2323
24+ implementation(libs.proguard)
25+
2426 testImplementation(kotlin(" test" ))
2527 testImplementation(libs.bundles.game.test)
2628 testImplementation(libs.bundles.kotlinxEcosystem)
@@ -29,3 +31,52 @@ dependencies {
2931 testImplementation(libs.bundles.r2dbc.drivers)
3032 testImplementation(libs.jbcrypt)
3133}
34+
35+ tasks.register<JavaExec >(" proguardJar" ) {
36+ val shadowJarFile = tasks.shadowJar.get().archiveFile.get().asFile
37+ val outputFile = File (buildDir, " libs/${project.name} -proguard.jar" )
38+
39+ // Make sure the output directory exists
40+ doFirst {
41+ outputFile.parentFile.mkdirs()
42+ }
43+
44+ // Configure the JavaExec task
45+ mainClass.set(" proguard.ProGuard" )
46+ classpath = configurations.runtimeClasspath.get()
47+
48+ // ProGuard arguments
49+ val argsList = mutableListOf (
50+ " -injars" , shadowJarFile.absolutePath,
51+ " -outjars" , outputFile.absolutePath,
52+ " -printmapping" , " ${buildDir} /proguard/mapping.txt" ,
53+ " -printseeds" , " ${buildDir} /proguard/seeds.txt" ,
54+ " -printusage" , " ${buildDir} /proguard/usage.txt" ,
55+ " @${rootProject.projectDir} /proguard-rules.pro"
56+ )
57+
58+ // Provide ALL compile+runtime classpath entries as library jars for analysis only
59+ // (exclude the fat shadow jar which is already passed as -injars)
60+ val runtimeFiles = configurations.runtimeClasspath.get().files
61+ val compileFiles = configurations.compileClasspath.get().files
62+ val allLibs = (runtimeFiles + compileFiles)
63+ .asSequence()
64+ .filter { it.exists() && it != shadowJarFile }
65+ .distinctBy { it.absolutePath }
66+ .toList()
67+ allLibs.forEach { file ->
68+ argsList.addAll(listOf (" -libraryjars" , file.absolutePath))
69+ }
70+
71+ args = argsList
72+ doFirst {
73+ File (" ${buildDir} /proguard" ).mkdirs()
74+ }
75+ }
76+
77+ tasks.test {
78+ testLogging {
79+ events(" failed" )
80+ exceptionFormat = TestExceptionFormat .SHORT
81+ }
82+ }
0 commit comments