initial commit
This commit is contained in:
153
bindings/kotlin/build.gradle.kts
Normal file
153
bindings/kotlin/build.gradle.kts
Normal file
@@ -0,0 +1,153 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "2.1.0"
|
||||
id("org.jetbrains.dokka") version "1.9.10"
|
||||
`maven-publish`
|
||||
signing
|
||||
}
|
||||
|
||||
group = "cz.jzitnik"
|
||||
version = "0.1.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
|
||||
implementation("net.java.dev.jna:jna:5.14.0")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
}
|
||||
|
||||
// Exclude native libs from the main JAR
|
||||
tasks.named<Jar>("jar") {
|
||||
exclude("linux-x86-64/**", "win32-x86-64/**")
|
||||
}
|
||||
|
||||
// Maven Central requires unique Javadoc and Sources for EVERY artifact
|
||||
fun createComponentJars(componentName: String, artifactBaseName: String): Pair<TaskProvider<Jar>, TaskProvider<Jar>> {
|
||||
val javadoc = tasks.register<Jar>("${componentName}JavadocJar") {
|
||||
archiveBaseName.set(artifactBaseName)
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.dokkaJavadoc)
|
||||
}
|
||||
val sources = tasks.register<Jar>("${componentName}SourcesJar") {
|
||||
archiveBaseName.set(artifactBaseName)
|
||||
archiveClassifier.set("sources")
|
||||
from(sourceSets.main.get().allSource)
|
||||
}
|
||||
return javadoc to sources
|
||||
}
|
||||
|
||||
val (commonJavadoc, commonSources) = createComponentJars("common", "jecna-supl-client")
|
||||
val (linuxJavadoc, linuxSources) = createComponentJars("linux", "jecna-supl-client-linux-x64")
|
||||
val (androidJavadoc, androidSources) = createComponentJars("android", "jecna-supl-client-android")
|
||||
val (windowsJavadoc, windowsSources) = createComponentJars("windows", "jecna-supl-client-windows-x64")
|
||||
|
||||
// Platform-specific JARs
|
||||
val linuxX64Jar by tasks.registering(Jar::class) {
|
||||
archiveBaseName.set("jecna-supl-client-linux-x64")
|
||||
from(sourceSets.main.get().resources) {
|
||||
include("linux-x86-64/**")
|
||||
}
|
||||
}
|
||||
|
||||
val androidJar by tasks.registering(Jar::class) {
|
||||
archiveBaseName.set("jecna-supl-client-android")
|
||||
from(sourceSets.main.get().resources) {
|
||||
include("lib/**")
|
||||
}
|
||||
}
|
||||
|
||||
val windowsX64Jar by tasks.registering(Jar::class) {
|
||||
archiveBaseName.set("jecna-supl-client-windows-x64")
|
||||
from(sourceSets.main.get().resources) {
|
||||
include("win32-x86-64/**")
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("common") {
|
||||
artifactId = "jecna-supl-client"
|
||||
from(components["java"])
|
||||
artifact(commonJavadoc)
|
||||
artifact(commonSources)
|
||||
pom.configureMetadata("Jecna Supl Client")
|
||||
}
|
||||
|
||||
create<MavenPublication>("linux") {
|
||||
artifactId = "jecna-supl-client-linux-x64"
|
||||
artifact(linuxX64Jar)
|
||||
artifact(linuxJavadoc)
|
||||
artifact(linuxSources)
|
||||
pom.configureMetadata("Jecna Supl Client - Linux x64")
|
||||
}
|
||||
|
||||
create<MavenPublication>("android") {
|
||||
artifactId = "jecna-supl-client-android"
|
||||
artifact(androidJar)
|
||||
artifact(androidJavadoc)
|
||||
artifact(androidSources)
|
||||
pom.configureMetadata("Jecna Supl Client - Android")
|
||||
}
|
||||
|
||||
create<MavenPublication>("windows") {
|
||||
artifactId = "jecna-supl-client-windows-x64"
|
||||
artifact(windowsX64Jar)
|
||||
artifact(windowsJavadoc)
|
||||
artifact(windowsSources)
|
||||
pom.configureMetadata("Jecna Supl Client - Windows x64")
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "Staging"
|
||||
url = uri(layout.buildDirectory.dir("staging-deploy"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun org.gradle.api.publish.maven.MavenPom.configureMetadata(nameStr: String) {
|
||||
name.set(nameStr)
|
||||
description.set("Kotlin bindings for the Jecna Supl Rust library")
|
||||
url.set("https://gitea.jzitnik.dev/jzitnik/jecna-supl-client")
|
||||
licenses {
|
||||
license {
|
||||
name.set("GNU Lesser General Public License, Version 3.0")
|
||||
url.set("https://www.gnu.org/licenses/lgpl-3.0.txt")
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id.set("jzitnik")
|
||||
name.set("Jakub Žitník")
|
||||
email.set("email@jzitnik.dev")
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection.set("scm:git:git://gitea.jzitnik.dev/jzitnik/jecna-supl-client.git")
|
||||
developerConnection.set("scm:git:ssh://gitea.jzitnik.dev/jzitnik/jecna-supl-client.git")
|
||||
url.set("https://gitea.jzitnik.dev/jzitnik/jecna-supl-client")
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign(publishing.publications)
|
||||
}
|
||||
|
||||
val zipBundle by tasks.registering(Zip::class) {
|
||||
group = "publishing"
|
||||
description = "Create a bundle for Sonatype Central manual upload"
|
||||
from(layout.buildDirectory.dir("staging-deploy"))
|
||||
archiveFileName.set("sonatype-bundle.zip")
|
||||
dependsOn("publishCommonPublicationToStagingRepository",
|
||||
"publishLinuxPublicationToStagingRepository",
|
||||
"publishAndroidPublicationToStagingRepository",
|
||||
"publishWindowsPublicationToStagingRepository")
|
||||
}
|
||||
Reference in New Issue
Block a user