Skip to content

Commit

Permalink
packaging: Remove dependency to Bisq 2 commons module
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Oct 8, 2024
1 parent 8b22dd1 commit 652a78c
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 10 deletions.
1 change: 0 additions & 1 deletion build-logic/packaging/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ gradlePlugin {
}

dependencies {
implementation(project(":commons"))
implementation("bitcoind-build-logic:gradle-tasks")
implementation(libs.commons.codec)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package bisq.gradle.packaging

import java.util.*

enum class Architecture(val architectureName: String) {
X86_64("x86_64"),
ARM_64("arm64"),
}

fun getArchitecture(): Architecture {
val architectureName = getArchitectureName()
if (isX86_64(architectureName)) {
return Architecture.X86_64
} else if (isArm64(architectureName)) {
return Architecture.ARM_64
}

throw IllegalStateException("Running on unsupported Architecture: $architectureName")
}

fun isX86_64(archName: String): Boolean {
return is64Bit(archName) && (archName.contains("x86") || archName.contains("amd"))
}

fun isArm64(archName: String): Boolean {
return is64Bit(archName) && (archName.contains("aarch") || archName.contains("arm"))
}

fun is64Bit(archName: String): Boolean {
return archName.contains("64")
}

fun getArchitectureName(): String {
return System.getProperty("os.arch").lowercase(Locale.US)
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package bisq.gradle.packaging

import bisq.gradle.common.OS
import bisq.gradle.common.getOS
import bisq.gradle.packaging.jpackage.JPackageAppConfig
import bisq.gradle.packaging.jpackage.JPackageConfig
import bisq.gradle.packaging.jpackage.PackageFactory
Expand Down
38 changes: 38 additions & 0 deletions build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/OS.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package bisq.gradle.packaging

import java.util.*

enum class OS(val osName: String) {
LINUX("linux"),
MAC_OS("macos"),
WINDOWS("win")
}

fun getOS(): OS {
val osName = getOSName()
if (isLinux(osName)) {
return OS.LINUX
} else if (isMacOs(osName)) {
return OS.MAC_OS
} else if (isWindows(osName)) {
return OS.WINDOWS
}

throw IllegalStateException("Running on unsupported OS: $osName")
}

private fun isLinux(osName: String): Boolean {
return osName.contains("linux")
}

private fun isMacOs(osName: String): Boolean {
return osName.contains("mac") || osName.contains("darwin")
}

private fun isWindows(osName: String): Boolean {
return osName.contains("win")
}

fun getOSName(): String {
return System.getProperty("os.name").lowercase(Locale.US)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package bisq.gradle.packaging

import bisq.gradle.common.OS
import bisq.gradle.common.getOS
import bisq.gradle.common.getPlatform
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.Directory
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package bisq.gradle.packaging

enum class Platform(val platformName: String) {
LINUX_X86_64("linux_x86_64"),
LINUX_ARM_64("linux_arm64"),

MACOS_X86_64("macos_x86_64"),
MACOS_ARM_64("macos_arm64"),

WIN_X86_64("win_x86_64"),
WIN_ARM_64("win_arm64")
}

fun getPlatform(): Platform {
val os = getOS()
val architecture = getArchitecture()
when (os) {
OS.LINUX -> {
return when (architecture) {
Architecture.X86_64 -> Platform.LINUX_X86_64
Architecture.ARM_64 -> Platform.LINUX_ARM_64
}
}

OS.MAC_OS -> {
return when (architecture) {
Architecture.X86_64 -> Platform.MACOS_X86_64
Architecture.ARM_64 -> Platform.MACOS_ARM_64
}
}

OS.WINDOWS -> {
return when (architecture) {
Architecture.X86_64 -> Platform.WIN_X86_64
Architecture.ARM_64 -> Platform.WIN_ARM_64
}
}
}
throw IllegalStateException("Running on unsupported Platform: ${os.osName} / ${architecture.architectureName}")
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package bisq.gradle.packaging

import bisq.gradle.common.Platform
import bisq.gradle.common.getPlatform
import org.gradle.api.Project
import org.gradle.api.file.Directory
import org.gradle.api.file.RegularFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package bisq.gradle.packaging

import bisq.gradle.common.OS
import bisq.gradle.common.getOS
import org.apache.commons.codec.binary.Hex
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
Expand Down

0 comments on commit 652a78c

Please sign in to comment.