Files
native-mdns/build.gradle.kts
T

128 lines
3.2 KiB
Kotlin
Raw Normal View History

2025-09-30 17:51:11 +08:00
import com.vanniktech.maven.publish.SonatypeHost
2025-09-29 01:56:32 +08:00
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2025-09-29 01:43:17 +08:00
plugins {
kotlin("multiplatform") version "2.2.0"
2025-09-30 17:51:11 +08:00
id("com.vanniktech.maven.publish") version "0.31.0-rc2"
id("signing")
2025-09-29 01:43:17 +08:00
}
2025-09-30 17:51:11 +08:00
val libVersion: String by project
2025-09-29 01:43:17 +08:00
group = "cn.rtast.nmdns"
2025-09-30 17:51:11 +08:00
version = libVersion
2025-09-29 01:43:17 +08:00
repositories {
mavenCentral()
}
kotlin {
2025-09-29 06:30:39 +08:00
val nativeTargets = listOf(
linuxArm64(),
linuxX64(),
mingwX64(),
2025-09-30 15:08:53 +08:00
macosArm64(),
macosX64()
2025-09-29 06:30:39 +08:00
)
2025-09-29 01:56:32 +08:00
jvm { compilerOptions { jvmTarget = JvmTarget.JVM_11 } }
2025-09-29 01:43:17 +08:00
2025-09-29 06:30:39 +08:00
nativeTargets.forEach {
it.binaries {
staticLib {
baseName = "nmdns"
}
sharedLib {
baseName = "nmdns"
}
}
}
compilerOptions { freeCompilerArgs.addAll("-Xexpect-actual-classes") }
explicitApi()
2025-09-29 01:43:17 +08:00
sourceSets {
commonMain.dependencies {
2025-09-29 01:43:17 +08:00
}
commonTest.dependencies {
implementation(kotlin("test"))
}
}
}
2025-09-29 01:56:32 +08:00
2025-09-30 17:51:11 +08:00
mavenPublishing {
publishing {
repositories {
mavenLocal()
maven("https://repo.maven.rtast.cn/releases") {
name = "RTAST"
credentials {
username = "RTAkland"
password = System.getenv("PUBLISH_TOKEN")
}
}
mavenCentral()
}
}
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
if (System.getenv("PUBLISH_TOKEN") == null) signAllPublications()
coordinates("cn.rtast.nmdns", project.name, libVersion)
pom {
name = project.name
description = "mDNS in kotlin multiplatform"
url = "https://github.com/RTAkland/native-mdns"
developers {
developer {
id = "rtakland"
name = "RTAkland"
email = "rtakland@outlook.com"
}
}
licenses {
license {
name = "The Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
2025-09-29 01:56:32 +08:00
}
}
2025-09-30 17:51:11 +08:00
scm {
url = "https://github.com/RTAkland/native-mdns"
connection = "scm:git:git://github.com/RTAkland/native-mdns.git"
developerConnection = "scm:git:ssh://git@github.com/RTAkland/native-mdns.git"
}
}
}
if (System.getenv("PUBLISH_TOKEN") == null) {
signing {
useGpgCmd()
sign(publishing.publications)
2025-09-29 01:56:32 +08:00
}
}
2025-09-29 06:30:39 +08:00
/**
* link all targets static lib
* Apple target can only be compiled on macos
*/
tasks.register("linkStaticLibrary") {
group = "nmdns"
dependsOn(tasks.named("linkReleaseStaticLinuxArm64"))
dependsOn(tasks.named("linkReleaseStaticLinuxX64"))
dependsOn(tasks.named("linkReleaseStaticMacosArm64"))
dependsOn(tasks.named("linkReleaseStaticMingwX64"))
}
/**
* link all targrts to shared lib
* Apple target can only be compiled on macos
*/
tasks.register("linkSharedLibrary") {
group = "nmdns"
dependsOn(tasks.named("linkReleaseSharedLinuxArm64"))
dependsOn(tasks.named("linkReleaseSharedLinuxX64"))
dependsOn(tasks.named("linkReleaseSharedMacosArm64"))
dependsOn(tasks.named("linkReleaseSharedMingwX64"))
}