bump kutil, allow defining platform and architecture with gradle properties

This commit is contained in:
Bixilon 2022-10-27 22:09:48 +02:00
parent 382088b8d5
commit bb5bc33b4b
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 16 additions and 14 deletions

View File

@ -45,6 +45,8 @@ val nettyVersion = getProperty("netty.version")
val jacksonVersion = getProperty("jackson.version") val jacksonVersion = getProperty("jackson.version")
val kutilVersion = getProperty("kutil.version") val kutilVersion = getProperty("kutil.version")
val os = properties["platform"]?.let { OSTypes[it] } ?: PlatformInfo.OS
val architecture = properties["architecture"]?.let { Architectures[it] } ?: PlatformInfo.ARCHITECTURE
repositories { repositories {
mavenCentral() mavenCentral()
@ -53,7 +55,7 @@ repositories {
buildscript { buildscript {
dependencies { dependencies {
classpath("de.bixilon", "kutil", "1.17") classpath("de.bixilon", "kutil", "1.17.1")
} }
} }
@ -61,13 +63,13 @@ var lwjglNatives = ""
var zstdNatives = "" var zstdNatives = ""
var javafxNatives = "" var javafxNatives = ""
when (PlatformInfo.OS) { when (os) {
OSTypes.LINUX -> { OSTypes.LINUX -> {
lwjglNatives += "linux" lwjglNatives += "linux"
zstdNatives += "linux" zstdNatives += "linux"
javafxNatives += "linux" javafxNatives += "linux"
when (PlatformInfo.ARCHITECTURE) { when (architecture) {
Architectures.AMD64 -> { Architectures.AMD64 -> {
zstdNatives += "_amd64" zstdNatives += "_amd64"
} }
@ -78,7 +80,7 @@ when (PlatformInfo.OS) {
javafxNatives += "-aarch64" javafxNatives += "-aarch64"
} }
else -> throw IllegalArgumentException("Can not determinate linux natives on ${PlatformInfo.ARCHITECTURE}") else -> throw IllegalArgumentException("Can not determinate linux natives on $architecture")
} }
} }
@ -87,7 +89,7 @@ when (PlatformInfo.OS) {
zstdNatives += "darwin" zstdNatives += "darwin"
javafxNatives += "mac" javafxNatives += "mac"
when (PlatformInfo.ARCHITECTURE) { when (architecture) {
Architectures.AMD64, Architectures.X86 -> { Architectures.AMD64, Architectures.X86 -> {
zstdNatives += "_x86_64" zstdNatives += "_x86_64"
} }
@ -98,7 +100,7 @@ when (PlatformInfo.OS) {
javafxNatives += "-aarch64" javafxNatives += "-aarch64"
} }
else -> throw IllegalArgumentException("Can not determinate macos natives on ${PlatformInfo.ARCHITECTURE}") else -> throw IllegalArgumentException("Can not determinate macos natives on $architecture")
} }
} }
@ -107,7 +109,7 @@ when (PlatformInfo.OS) {
zstdNatives += "win" zstdNatives += "win"
javafxNatives += "win" javafxNatives += "win"
when (PlatformInfo.ARCHITECTURE) { when (architecture) {
Architectures.AMD64 -> { Architectures.AMD64 -> {
zstdNatives += "_amd64" zstdNatives += "_amd64"
} }
@ -118,12 +120,12 @@ when (PlatformInfo.OS) {
javafxNatives += "-x86" javafxNatives += "-x86"
} }
else -> throw IllegalArgumentException("Can not determinate windows natives on ${PlatformInfo.ARCHITECTURE}") else -> throw IllegalArgumentException("Can not determinate windows natives on $architecture")
} }
} }
else -> { else -> {
throw IllegalArgumentException("Can not determinate natives for ${PlatformInfo.OS} on ${PlatformInfo.ARCHITECTURE}") throw IllegalArgumentException("Can not determinate natives for $os on $architecture")
} }
} }
@ -344,11 +346,11 @@ dependencies {
// platform specific // platform specific
if (PlatformInfo.OS == OSTypes.LINUX) { if (os == OSTypes.LINUX) {
val nettyNatives = when (PlatformInfo.ARCHITECTURE) { val nettyNatives = when (architecture) {
Architectures.AMD64, Architectures.X86 -> "x86_64" Architectures.AMD64, Architectures.X86 -> "x86_64"
Architectures.ARM, Architectures.AARCH64 -> "aarch64" Architectures.ARM, Architectures.AARCH64 -> "aarch64"
else -> throw IllegalArgumentException("Can not determinate netty natives for ${PlatformInfo.ARCHITECTURE}") else -> throw IllegalArgumentException("Can not determinate netty natives for $architecture")
} }
implementation("io.netty", "netty-transport-native-epoll", nettyVersion, classifier = "linux-$nettyNatives") implementation("io.netty", "netty-transport-native-epoll", nettyVersion, classifier = "linux-$nettyNatives")
} else { } else {
@ -435,7 +437,7 @@ application {
} }
val fatJar = task("fatJar", type = Jar::class) { val fatJar = task("fatJar", type = Jar::class) {
archiveBaseName.set("${project.name}-fat-${PlatformInfo.OS.name.toLowerCase()}-${PlatformInfo.ARCHITECTURE.name.toLowerCase()}") archiveBaseName.set("${project.name}-fat-${os.name.toLowerCase()}-${architecture.name.toLowerCase()}")
manifest { manifest {
attributes["Implementation-Title"] = project.name.capitalized() attributes["Implementation-Title"] = project.name.capitalized()
attributes["Implementation-Version"] = project.version attributes["Implementation-Version"] = project.version

View File

@ -17,4 +17,4 @@ lwjgl.version=3.3.2-SNAPSHOT
ikonli.version=12.3.1 ikonli.version=12.3.1
netty.version=4.1.82.Final netty.version=4.1.82.Final
jackson.version=2.13.4 jackson.version=2.13.4
kutil.version=1.17 kutil.version=1.17.1