Skip to content

Commit

Permalink
Tweak rename task
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Jun 17, 2024
1 parent a8444ba commit c1942a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
name: distribution-${{ matrix.os }}
if-no-files-found: error
path: |
build/compose/binaries/main/dmg/*.dmg
build/compose/binaries/main/dmg/kotlin-explorer-*.dmg
release:
runs-on: ubuntu-latest
Expand Down
32 changes: 16 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask
import kotlin.io.path.exists
import kotlin.io.path.listDirectoryEntries
import kotlin.io.path.moveTo

plugins {
alias(libs.plugins.kotlin.multiplatform)
Expand All @@ -20,6 +18,7 @@ repositories {
}

version = "1.4.3"
val baseName = "Kotlin Explorer"

kotlin {
jvm {
Expand Down Expand Up @@ -80,8 +79,8 @@ compose.desktop {
targetFormats(TargetFormat.Dmg)

packageVersion = version.toString()
packageName = "Kotlin Explorer"
description = "Kotlin Explorer"
packageName = baseName
description = baseName
vendor = "Romain Guy"
licenseFile = rootProject.file("LICENSE")

Expand All @@ -103,23 +102,24 @@ val currentArch: String = when (val osArch = System.getProperty("os.arch")) {
/**
* TODO: workaround for https://github.com/JetBrains/compose-multiplatform/issues/4976.
*/
val renameDmg by tasks.registering {
val renameDmg by tasks.registering(Copy::class) {
group = "distribution"
description = "Rename the DMG file"

val packageDmg = tasks.named<AbstractJPackageTask>("packageDmg")
dependsOn(packageDmg)

doLast {
// build/compose/binaries/main/dmg/*.dmg
val targetFile = packageDmg.get().appImage.get().dir("../dmg").asFile.toPath()
.listDirectoryEntries("*.dmg").single()
check(targetFile.exists()) {
"The DMG file does not exist: $targetFile"
}
targetFile.moveTo(targetFile.resolveSibling("kotlin-explorer-$currentArch-$version.dmg"))
// build/compose/binaries/main/dmg/*.dmg
val fromFile = packageDmg.map {
it.appImage.get().dir("../dmg").asFile.toPath()
.listDirectoryEntries("$baseName*.dmg").single()
}

from(fromFile)
into(fromFile.map { it.parent })
rename {
"kotlin-explorer-$currentArch-$version.dmg"
}
}

tasks.build {
tasks.assemble {
dependsOn(renameDmg)
}

0 comments on commit c1942a1

Please sign in to comment.