mirror of
https://github.com/bisq-network/bisq.git
synced 2025-01-19 05:44:05 +01:00
Implement custom toolchain resolver
This commit is contained in:
parent
e0164dfc1b
commit
fea0e69fc7
@ -11,4 +11,5 @@ include 'commons'
|
|||||||
include 'gradle-tasks'
|
include 'gradle-tasks'
|
||||||
include 'packaging'
|
include 'packaging'
|
||||||
include 'regtest'
|
include 'regtest'
|
||||||
|
include 'toolchain-resolver'
|
||||||
include 'tor-binary'
|
include 'tor-binary'
|
||||||
|
17
build-logic/toolchain-resolver/build.gradle
Normal file
17
build-logic/toolchain-resolver/build.gradle
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
plugins {
|
||||||
|
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
|
||||||
|
id 'org.gradle.kotlin.kotlin-dsl' version '2.4.1'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
gradlePlugin {
|
||||||
|
plugins {
|
||||||
|
simplePlugin {
|
||||||
|
id = 'bisq.gradle.toolchain_resolver.ToolchainResolverPlugin'
|
||||||
|
implementationClass = 'bisq.gradle.toolchain_resolver.ToolchainResolverPlugin'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package bisq.gradle.toolchain_resolver
|
||||||
|
|
||||||
|
import org.gradle.jvm.toolchain.JavaToolchainDownload
|
||||||
|
import org.gradle.jvm.toolchain.JavaToolchainRequest
|
||||||
|
import org.gradle.jvm.toolchain.JavaToolchainResolver
|
||||||
|
import org.gradle.platform.OperatingSystem
|
||||||
|
import java.net.URI
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
abstract class BisqToolchainResolver : JavaToolchainResolver {
|
||||||
|
override fun resolve(toolchainRequest: JavaToolchainRequest): Optional<JavaToolchainDownload> {
|
||||||
|
val operatingSystem = toolchainRequest.buildPlatform.operatingSystem
|
||||||
|
val javaVersion = toolchainRequest.javaToolchainSpec.languageVersion.get().asInt()
|
||||||
|
|
||||||
|
val toolchainUrl: String = when (operatingSystem) {
|
||||||
|
OperatingSystem.LINUX -> getToolchainUrlForLinux(javaVersion)
|
||||||
|
OperatingSystem.MAC_OS -> getToolchainUrlForMacOs(javaVersion)
|
||||||
|
OperatingSystem.WINDOWS -> getToolchainUrlForWindows(javaVersion)
|
||||||
|
else -> null
|
||||||
|
|
||||||
|
} ?: return Optional.empty()
|
||||||
|
|
||||||
|
val uri = URI(toolchainUrl)
|
||||||
|
return Optional.of(
|
||||||
|
JavaToolchainDownload.fromUri(uri)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getToolchainUrlForLinux(javaVersion: Int): String? =
|
||||||
|
when (javaVersion) {
|
||||||
|
11 -> "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.zip"
|
||||||
|
17 -> "https://cdn.azul.com/zulu/bin/zulu17.44.15-ca-jdk17.0.8-linux_x64.zip"
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getToolchainUrlForMacOs(javaVersion: Int): String? =
|
||||||
|
when (javaVersion) {
|
||||||
|
11 -> "https://cdn.azul.com/zulu/bin/zulu11.66.15_1-ca-jdk11.0.20-macosx_x64.tar.gz"
|
||||||
|
17 -> "https://cdn.azul.com/zulu/bin/zulu17.44.15_1-ca-jdk17.0.8-macosx_x64.tar.gz"
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getToolchainUrlForWindows(javaVersion: Int): String? =
|
||||||
|
when (javaVersion) {
|
||||||
|
11 -> "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip"
|
||||||
|
17 -> "https://cdn.azul.com/zulu/bin/zulu17.44.15-ca-jdk17.0.8-win_x64.zip"
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package bisq.gradle.toolchain_resolver
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.initialization.Settings
|
||||||
|
import org.gradle.jvm.toolchain.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
class ToolchainResolverPlugin @Inject constructor(private val toolchainResolverRegistry: JavaToolchainResolverRegistry) : Plugin<Settings> {
|
||||||
|
|
||||||
|
override fun apply(settings: Settings) {
|
||||||
|
settings.plugins.apply("jvm-toolchain-management")
|
||||||
|
toolchainResolverRegistry.register(BisqToolchainResolver::class.java)
|
||||||
|
}
|
||||||
|
}
|
@ -6,14 +6,14 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("org.gradle.toolchains.foojay-resolver") version "0.7.0"
|
id 'bisq.gradle.toolchain_resolver.ToolchainResolverPlugin'
|
||||||
}
|
}
|
||||||
|
|
||||||
toolchainManagement {
|
toolchainManagement {
|
||||||
jvm {
|
jvm {
|
||||||
javaRepositories {
|
javaRepositories {
|
||||||
repository("foojay") {
|
repository("bisq_zulu") {
|
||||||
resolverClass = org.gradle.toolchains.foojay.FoojayToolchainResolver
|
resolverClass = bisq.gradle.toolchain_resolver.BisqToolchainResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user