From cc0693ef250b15efcc086e064d6f0c11e6591eea Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Sun, 25 Aug 2024 13:53:57 +0700 Subject: [PATCH 1/3] Add dependency to commons --- build-logic/gradle-tasks/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build-logic/gradle-tasks/build.gradle.kts b/build-logic/gradle-tasks/build.gradle.kts index 7209b3b871..52cc1ff095 100644 --- a/build-logic/gradle-tasks/build.gradle.kts +++ b/build-logic/gradle-tasks/build.gradle.kts @@ -8,5 +8,6 @@ repositories { } dependencies { + implementation(project(":commons")) implementation(libs.bouncycastle.pg) } \ No newline at end of file From 84d6f4768a84fad9cdcc29fc58ad549a1bbae552 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Sun, 25 Aug 2024 13:57:04 +0700 Subject: [PATCH 2/3] Add entry for MACOS_ARM_64 to PerOsUrlProvider. Rename to match naming of Platform enums --- .../BitcoinCoreHashFileUrlProvider.kt | 9 +++++--- .../electrum/ElectrumBinaryUrlProvider.kt | 9 +++++--- .../bisq/gradle/tasks/PerOsUrlProvider.kt | 23 ++++++++++++------- .../gradle/tor_binary/TorBinaryUrlProvider.kt | 13 ++++++++--- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCoreHashFileUrlProvider.kt b/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCoreHashFileUrlProvider.kt index 70d529e6e3..5aba4fa037 100644 --- a/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCoreHashFileUrlProvider.kt +++ b/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCoreHashFileUrlProvider.kt @@ -6,12 +6,15 @@ class BitcoinCoreHashFileUrlProvider(private val version: String) : PerOsUrlProv override val urlPrefix: String get() = "https://bitcoincore.org/bin/bitcoin-core-$version/SHA256SUMS" - override val linuxUrl: String + override val LINUX_X86_64_URL: String get() = "" - override val macOsUrl: String + override val MACOS_X86_64_URL: String get() = "" - override val windowsUrl: String + override val MACOS_ARM_64_URL: String + get() = "" + + override val WIN_X86_64_URL: String get() = "" } \ No newline at end of file diff --git a/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/ElectrumBinaryUrlProvider.kt b/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/ElectrumBinaryUrlProvider.kt index 027fcd8483..35e916f0c6 100644 --- a/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/ElectrumBinaryUrlProvider.kt +++ b/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/ElectrumBinaryUrlProvider.kt @@ -6,12 +6,15 @@ class ElectrumBinaryUrlProvider(private val version: String) : PerOsUrlProvider override val urlPrefix: String get() = "https://download.electrum.org/$version/" - override val linuxUrl: String + override val LINUX_X86_64_URL: String get() = "electrum-$version-x86_64.AppImage" - override val macOsUrl: String + override val MACOS_X86_64_URL: String get() = "electrum-$version.dmg" - override val windowsUrl: String + override val MACOS_ARM_64_URL: String + get() = "electrum-$version.dmg" // No ARM_64 version provided + + override val WIN_X86_64_URL: String get() = "electrum-$version.exe" } \ No newline at end of file diff --git a/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/PerOsUrlProvider.kt b/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/PerOsUrlProvider.kt index 5e4017574b..4d0602871c 100644 --- a/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/PerOsUrlProvider.kt +++ b/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/PerOsUrlProvider.kt @@ -1,20 +1,27 @@ package bisq.gradle.tasks +import bisq.gradle.common.Platform.* +import bisq.gradle.common.getPlatform + interface PerOsUrlProvider { val urlPrefix: String - val linuxUrl: String - val macOsUrl: String - val windowsUrl: String + val LINUX_X86_64_URL: String + val MACOS_X86_64_URL: String + val MACOS_ARM_64_URL: String + val WIN_X86_64_URL: String val url: String get() = urlPrefix + getUrlSuffix() private fun getUrlSuffix() = - when (getOS()) { - OS.LINUX -> linuxUrl - OS.MAC_OS -> macOsUrl - OS.WINDOWS -> windowsUrl - } + when (getPlatform()) { + LINUX_X86_64 -> LINUX_X86_64_URL + LINUX_ARM_64 -> LINUX_X86_64_URL // No ARM_64 provided + MACOS_X86_64 -> MACOS_X86_64_URL + MACOS_ARM_64 -> MACOS_ARM_64_URL + WIN_X86_64 -> WIN_X86_64_URL + WIN_ARM_64 -> WIN_X86_64_URL // No ARM_64 provided + } } \ No newline at end of file diff --git a/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/TorBinaryUrlProvider.kt b/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/TorBinaryUrlProvider.kt index 4a29f4aaa9..fc1c8b67ea 100644 --- a/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/TorBinaryUrlProvider.kt +++ b/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/TorBinaryUrlProvider.kt @@ -6,12 +6,19 @@ class TorBinaryUrlProvider(private val version: String) : PerOsUrlProvider { override val urlPrefix: String get() = "https://archive.torproject.org/tor-package-archive/torbrowser/$version/" - override val linuxUrl: String + override val LINUX_X86_64_URL: String get() = "tor-expert-bundle-linux-x86_64-$version.tar.gz" - override val macOsUrl: String + override val MACOS_X86_64_URL: String get() = "tor-expert-bundle-macos-x86_64-$version.tar.gz" - override val windowsUrl: String + override val MACOS_ARM_64_URL: String + // Currently the Tor version for aarch64 does not work, thus we use the x64 version. + // See: https://github.com/bisq-network/bisq2/issues/2679 + // Once resolved we can use the line below. + // get() = "tor-expert-bundle-macos-aarch64-$version.tar.gz" + get() = "tor-expert-bundle-macos-x86_64-$version.tar.gz" + + override val WIN_X86_64_URL: String get() = "tor-expert-bundle-windows-x86_64-$version.tar.gz" } \ No newline at end of file From 4a432b93cfff3b671d8d9aa9ff0ad01d4c83da13 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Sun, 25 Aug 2024 13:57:36 +0700 Subject: [PATCH 3/3] Refactor: Rename PerOsUrlProvider to PerPlatformUrlProvider --- .../gradle/bitcoin_core/BitcoinCoreHashFileUrlProvider.kt | 4 ++-- .../kotlin/bisq/gradle/bitcoin_core/BitcoinCorePlugin.kt | 2 +- .../main/kotlin/bisq/gradle/electrum/BisqElectrumPlugin.kt | 2 +- .../bisq/gradle/electrum/ElectrumBinaryUrlProvider.kt | 4 ++-- .../{PerOsUrlProvider.kt => PerPlatformUrlProvider.kt} | 2 +- .../bisq/gradle/tasks/download/SignedBinaryDownloader.kt | 6 +++--- .../kotlin/bisq/gradle/tor_binary/BisqTorBinaryPlugin.kt | 2 +- .../kotlin/bisq/gradle/tor_binary/TorBinaryUrlProvider.kt | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) rename build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/{PerOsUrlProvider.kt => PerPlatformUrlProvider.kt} (95%) diff --git a/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCoreHashFileUrlProvider.kt b/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCoreHashFileUrlProvider.kt index 5aba4fa037..be6a739f05 100644 --- a/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCoreHashFileUrlProvider.kt +++ b/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCoreHashFileUrlProvider.kt @@ -1,8 +1,8 @@ package bisq.gradle.bitcoin_core -import bisq.gradle.tasks.PerOsUrlProvider +import bisq.gradle.tasks.PerPlatformUrlProvider -class BitcoinCoreHashFileUrlProvider(private val version: String) : PerOsUrlProvider { +class BitcoinCoreHashFileUrlProvider(private val version: String) : PerPlatformUrlProvider { override val urlPrefix: String get() = "https://bitcoincore.org/bin/bitcoin-core-$version/SHA256SUMS" diff --git a/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCorePlugin.kt b/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCorePlugin.kt index 271d90649d..958d35fd8c 100644 --- a/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCorePlugin.kt +++ b/build-logic/bitcoin-core-binaries/src/main/kotlin/bisq/gradle/bitcoin_core/BitcoinCorePlugin.kt @@ -22,7 +22,7 @@ class BitcoinCorePlugin : Plugin { binaryName = "BitcoinCoreSha256Sums", version = extension.version, - perOsUrlProvider = { version -> BitcoinCoreHashFileUrlProvider(version) }, + perPlatformUrlProvider = { version -> BitcoinCoreHashFileUrlProvider(version) }, downloadDirectory = DOWNLOADS_DIR, pgpFingerprintToKeyUrlMap = mapOf( diff --git a/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/BisqElectrumPlugin.kt b/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/BisqElectrumPlugin.kt index 7b384d8592..41e29ac270 100644 --- a/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/BisqElectrumPlugin.kt +++ b/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/BisqElectrumPlugin.kt @@ -22,7 +22,7 @@ class BisqElectrumPlugin : Plugin { binaryName = "Electrum", version = extension.version, - perOsUrlProvider = { version -> ElectrumBinaryUrlProvider(version) }, + perPlatformUrlProvider = { version -> ElectrumBinaryUrlProvider(version) }, downloadDirectory = DOWNLOADS_DIR, pgpFingerprintToKeyUrlMap = mapOf( diff --git a/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/ElectrumBinaryUrlProvider.kt b/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/ElectrumBinaryUrlProvider.kt index 35e916f0c6..f2b16e5b89 100644 --- a/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/ElectrumBinaryUrlProvider.kt +++ b/build-logic/electrum-binaries/src/main/kotlin/bisq/gradle/electrum/ElectrumBinaryUrlProvider.kt @@ -1,8 +1,8 @@ package bisq.gradle.electrum -import bisq.gradle.tasks.PerOsUrlProvider +import bisq.gradle.tasks.PerPlatformUrlProvider -class ElectrumBinaryUrlProvider(private val version: String) : PerOsUrlProvider { +class ElectrumBinaryUrlProvider(private val version: String) : PerPlatformUrlProvider { override val urlPrefix: String get() = "https://download.electrum.org/$version/" diff --git a/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/PerOsUrlProvider.kt b/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/PerPlatformUrlProvider.kt similarity index 95% rename from build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/PerOsUrlProvider.kt rename to build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/PerPlatformUrlProvider.kt index 4d0602871c..97068c3b0d 100644 --- a/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/PerOsUrlProvider.kt +++ b/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/PerPlatformUrlProvider.kt @@ -3,7 +3,7 @@ package bisq.gradle.tasks import bisq.gradle.common.Platform.* import bisq.gradle.common.getPlatform -interface PerOsUrlProvider { +interface PerPlatformUrlProvider { val urlPrefix: String val LINUX_X86_64_URL: String diff --git a/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/download/SignedBinaryDownloader.kt b/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/download/SignedBinaryDownloader.kt index bcf974e62f..fe602aa551 100644 --- a/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/download/SignedBinaryDownloader.kt +++ b/build-logic/gradle-tasks/src/main/kotlin/bisq/gradle/tasks/download/SignedBinaryDownloader.kt @@ -1,6 +1,6 @@ package bisq.gradle.tasks.download -import bisq.gradle.tasks.PerOsUrlProvider +import bisq.gradle.tasks.PerPlatformUrlProvider import bisq.gradle.tasks.signature.SignatureVerificationTask import org.gradle.api.Project import org.gradle.api.provider.Property @@ -14,7 +14,7 @@ class SignedBinaryDownloader( private val binaryName: String, private val version: Property, - private val perOsUrlProvider: (String) -> PerOsUrlProvider, + private val perPlatformUrlProvider: (String) -> PerPlatformUrlProvider, private val downloadDirectory: String, private val pgpFingerprintToKeyUrlMap: Map @@ -23,7 +23,7 @@ class SignedBinaryDownloader( private val downloadTaskFactory = DownloadTaskFactory(project, downloadDirectory) fun registerTasks() { - val binaryDownloadUrl: Provider = version.map { perOsUrlProvider(it).url } + val binaryDownloadUrl: Provider = version.map { perPlatformUrlProvider(it).url } val binaryDownloadTask = downloadTaskFactory.registerDownloadTask("download${binaryName}Binary", binaryDownloadUrl) diff --git a/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/BisqTorBinaryPlugin.kt b/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/BisqTorBinaryPlugin.kt index 747f148077..c6e0823666 100644 --- a/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/BisqTorBinaryPlugin.kt +++ b/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/BisqTorBinaryPlugin.kt @@ -19,7 +19,7 @@ class BisqTorBinaryPlugin : Plugin { binaryName = "Tor", version = extension.version, - perOsUrlProvider = { version -> TorBinaryUrlProvider(version) }, + perPlatformUrlProvider = { version -> TorBinaryUrlProvider(version) }, downloadDirectory = DOWNLOADS_DIR, pgpFingerprintToKeyUrlMap = mapOf( diff --git a/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/TorBinaryUrlProvider.kt b/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/TorBinaryUrlProvider.kt index fc1c8b67ea..4945423bd9 100644 --- a/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/TorBinaryUrlProvider.kt +++ b/build-logic/tor-binary/src/main/kotlin/bisq/gradle/tor_binary/TorBinaryUrlProvider.kt @@ -1,8 +1,8 @@ package bisq.gradle.tor_binary -import bisq.gradle.tasks.PerOsUrlProvider +import bisq.gradle.tasks.PerPlatformUrlProvider -class TorBinaryUrlProvider(private val version: String) : PerOsUrlProvider { +class TorBinaryUrlProvider(private val version: String) : PerPlatformUrlProvider { override val urlPrefix: String get() = "https://archive.torproject.org/tor-package-archive/torbrowser/$version/"