forked from bisq-network/bisq2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
plugins { | ||
`java-gradle-plugin` | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
create("ToolchainResolverPlugin") { | ||
id = "bisq.gradle.toolchain_resolver.ToolchainResolverPlugin" | ||
implementationClass = "bisq.gradle.toolchain_resolver.ToolchainResolverPlugin" | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...oolchain-resolver/src/main/kotlin/bisq/gradle/toolchain_resolver/BisqToolchainResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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" | ||
15 -> "https://cdn.azul.com/zulu/bin/zulu15.46.17-ca-jdk15.0.10-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 | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...lchain-resolver/src/main/kotlin/bisq/gradle/toolchain_resolver/ToolchainResolverPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters