Skip to content

Commit

Permalink
Configuration to release on maven central
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Vasco committed Oct 16, 2024
1 parent 6eab989 commit a7503ea
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 5 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ To add the library using **Maven**, include the following dependency:

To add the library using **Gradle**, include:

```gradle
```kotlin
dependencies {
implementation('com.lightstreamer:ls-kotlin-mini-client:0.1.0')
}
Expand Down Expand Up @@ -103,16 +103,29 @@ To build the Lightstreamer Kotlin client, make sure you have [SDKMAN!](https://s

First, set up the dependencies defined in [.sdkmanrc](.sdkmanrc):

```sh
```shell
sdk env install
```

Then build and test using Gradle:

```sh
```shell
gradle build
```

## Publish library on Maven Central

This library is published in the Maven Central Repository.
To release a new version, you need the signature key and Sonatype's Access Token.

```shell
export SONATYPE_TOKEN=...
export SONATYPE_TOKEN_PASSWORD='...'
gradle publish
```

Then access to staging repository, close and publish it.

## Documentation

- [API reference](https://lightstreamer.github.io/Lightstreamer-lib-client-mini-kotlin/)
Expand Down
85 changes: 85 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import org.jetbrains.dokka.gradle.DokkaTask

description = "Kotlin mini client"

plugins {
kotlin("jvm") version "2.0.20"
id("org.jetbrains.dokka") version "1.9.20"
id("maven-publish")
id("signing")
}

allprojects {
Expand All @@ -16,11 +22,90 @@ subprojects {
apply(plugin = "kotlin")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "maven-publish")
apply(plugin = "signing")

version = parent?.version ?: error("Parent version not found")

kotlin {
explicitApi()
jvmToolchain(21)
}

// artifact: sources
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}

// artifact: javadoc
val dokkaOutputDir = layout.buildDirectory.dir("dokka")
tasks.getByName<DokkaTask>("dokkaHtml") {
outputDirectory.set(dokkaOutputDir)
}
val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
delete(dokkaOutputDir)
}
val javadocJar = tasks.register<Jar>("javadocJar") {
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
artifact(sourcesJar)
artifact(javadocJar)

pom {
name.set(project.name)
description.set("Lightstreamer Kotlin mini client")
url.set("https://github.com/Lightstreamer/Lightstreamer-lib-client-mini-kotlin")
issueManagement {
description.set("GitHub repository")
system.set("github")
url.set("https://github.com/Lightstreamer/Lightstreamer-lib-client-mini-kotlin/issues")
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("Lightstreamer Support")
email.set("support@lightstreamer.com")
}
}
scm {
description.set("GitHub repository")
connection.set("scm:git:git://github.com/Lightstreamer/Lightstreamer-lib-client-mini-kotlin.git")
developerConnection.set("scm:git:ssh://github.com/Lightstreamer/Lightstreamer-lib-client-mini-kotlin.git")
url.set("https://github.com/Lightstreamer/Lightstreamer-lib-client-mini-kotlin")
}
}
}
}

signing {
useGpgCmd()
sign(publishing.publications["mavenJava"])
}

publishing {
repositories {
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("SONATYPE_TOKEN")
password = System.getenv("SONATYPE_TOKEN_PASSWORD")
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion client/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
description = "Lightstreamer client"
description = "Lightstreamer Kotlin mini client"

dependencies {
api(project(":ls-kotlin-mini-socket"))
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
signing.keyId=6F29B4D2
signing.gnupg.keyName=support@lightstreamer.com
# -Psigning.gnupg.passphrase=
2 changes: 1 addition & 1 deletion socket/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
description = "TLCP parser"
description = "Create WebSocket and parse TLCP"

dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.9.0")
Expand Down

0 comments on commit a7503ea

Please sign in to comment.