@@ -4,6 +4,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
44import org.gradle.internal.os.OperatingSystem
55import org.gradle.jvm.tasks.Jar
66import org.jetbrains.compose.desktop.application.dsl.TargetFormat
7+ import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask
78import plugin.spmp.SpMpDeps
89import plugin.spmp.getDeps
910import java.io.FileInputStream
@@ -17,10 +18,6 @@ plugins {
1718 id(" org.jetbrains.compose" )
1819}
1920
20- enum class OS {
21- LINUX , WINDOWS ;
22- }
23-
2421val local_properties_path: String = " local.properties"
2522val strings_file: File = rootProject.file(" shared/src/commonMain/resources/assets/values/strings.xml" )
2623
@@ -207,30 +204,8 @@ abstract class ActuallyPackageAppImageTask: DefaultTask() {
207204
208205 project.logger.lifecycle(" Removing unneeded jars" )
209206
210- val deps: SpMpDeps = project.getDeps()
211- val ffmpeg_version: String = deps.getVersion(" org.bytedeco:ffmpeg-platform" )
212- val javacpp_version: String = ffmpeg_version.split(' -' , limit = 2 )[1 ]
213-
214- val platforms: List <String > = JarUtil .getUnneededPlatforms(is_windows = false )
215- val jar_prefixes: List <String > = platforms.flatMap { platform ->
216- JarUtil .getUnneededLibraries().map { library ->
217- val version: String =
218- when (library) {
219- " javacpp" -> javacpp_version
220- " ffmpeg" -> ffmpeg_version
221- else -> throw NotImplementedError (library)
222- }
223- return @map " $library -$version -$platform "
224- }
225- }
226-
227- for (file in dir.resolve(" lib/app" ).listFiles().orEmpty()) {
228- for (prefix in jar_prefixes) {
229- if (file.name.startsWith(prefix) && file.name.endsWith(" .jar" )) {
230- file.delete()
231- project.logger.lifecycle(" Removing lib/app/${file.name} " )
232- }
233- }
207+ with (JarUtil ) {
208+ dir.resolve(" lib/app" ).removeUnneededJarsFromDir(project)
234209 }
235210 }
236211
@@ -353,6 +328,33 @@ private object JarUtil {
353328 }
354329 )
355330 }
331+
332+ fun File.removeUnneededJarsFromDir (project : Project , deps : SpMpDeps = project.getDeps()) {
333+ val ffmpeg_version: String = deps.getVersion(" org.bytedeco:ffmpeg-platform" )
334+ val javacpp_version: String = ffmpeg_version.split(' -' , limit = 2 )[1 ]
335+
336+ val platforms: List <String > = JarUtil .getUnneededPlatforms(is_windows = false )
337+ val jar_prefixes: List <String > = platforms.flatMap { platform ->
338+ JarUtil .getUnneededLibraries().map { library ->
339+ val version: String =
340+ when (library) {
341+ " javacpp" -> javacpp_version
342+ " ffmpeg" -> ffmpeg_version
343+ else -> throw NotImplementedError (library)
344+ }
345+ return @map " $library -$version -$platform "
346+ }
347+ }
348+
349+ for (file in this .listFiles().orEmpty()) {
350+ for (prefix in jar_prefixes) {
351+ if (file.name.startsWith(prefix) && file.name.endsWith(" .jar" )) {
352+ file.delete()
353+ project.logger.lifecycle(" Removing lib/app/${file.name} " )
354+ }
355+ }
356+ }
357+ }
356358}
357359
358360afterEvaluate {
@@ -362,4 +364,30 @@ afterEvaluate {
362364 tasks.named<Jar >(" packageReleaseUberJarForCurrentOS" ) {
363365 with (JarUtil ) { excludeUnneededFiles() }
364366 }
367+
368+ tasks.withType<AbstractJPackageTask > {
369+ doLast {
370+ val jars_directory: File = outputs.files.singleFile.resolve(" spmp/lib/app" )
371+ with (JarUtil ) {
372+ jars_directory.removeUnneededJarsFromDir(project)
373+ }
374+ }
375+ }
376+ }
377+
378+ tasks.register<Tar >(" createReleaseTarball" ) {
379+ val dist_task: Task by tasks.named(" createReleaseDistributable" )
380+ val dist_directory: File = dist_task.outputs.files.singleFile
381+ dependsOn(dist_task)
382+
383+ val platform: String =
384+ if (Os .isFamily(Os .FAMILY_WINDOWS )) " windows-x86_64"
385+ else " linux-x86_64"
386+
387+ into(" /" ) {
388+ from(dist_directory)
389+ }
390+
391+ archiveFileName = " spmp-v${getString(" version_string" )} -$platform .tar.gz"
392+ compression = Compression .GZIP
365393}
0 commit comments