Skip to content

Commit 968dd49

Browse files
authored
Merge pull request #8 from meta-llama/maven-publish
Update gradle to support maven central publishing
2 parents 90366b4 + 719b848 commit 968dd49

File tree

6 files changed

+59
-81
lines changed

6 files changed

+59
-81
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
88

99
## Documentation
1010

11-
The REST API documentation can be found on [llama-stack](https://docs.llama-stack-client.todo) repo.
11+
The REST API documentation can be found on [llama-stack.readthedocs.io](https://llama-stack.readthedocs.io/en/latest/).
1212

1313
---
1414

1515
## Getting started
1616

17-
### Build the jar packages
17+
#### Gradle (Recommended) [![Maven version](https://img.shields.io/maven-central/v/com.llama.llamastack/llama-stack-client-kotlin)](https://central.sonatype.com/artifact/com.llama.llamastack/llama-stack-client-kotlin)
18+
19+
```kotlin
20+
implementation("com.llama.llamastack:llama-stack-client-kotlin:0.0.1-alpha.1")
21+
```
22+
23+
### Manually build the jar packages
1824

1925
In your terminal, under the `llama-stack-client-kotlin` directory, run the following command:
2026

@@ -25,8 +31,6 @@ sh build-libs.sh
2531
Output: .jar files located in the build-jars directory
2632

2733

28-
Note: Maven dependencies are not available at the moment. We will made it available in the near future once the SDK stabilizes. For now, build the Kotlin SDK jars manually and include them in your projects.
29-
3034
### Configure the client
3135

3236
Use `LlamaStackClientOkHttpClient.builder()` to configure the client.

build.gradle.kts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
plugins {
2-
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
2+
33
}
44

55
allprojects {
66
group = "com.llama.llamastack"
7-
version = "0.0.1-alpha.0"
8-
}
9-
10-
nexusPublishing {
11-
repositories {
12-
sonatype {
13-
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
14-
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
15-
16-
username.set(System.getenv("SONATYPE_USERNAME"))
17-
password.set(System.getenv("SONATYPE_PASSWORD"))
18-
}
19-
}
20-
}
7+
version = "0.0.1-alpha.1"
8+
}

buildSrc/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
plugins {
22
`kotlin-dsl`
3+
kotlin("jvm") version "1.9.22"
4+
id("com.vanniktech.maven.publish") version "0.28.0"
35
}
46

57
repositories {
68
gradlePluginPortal()
9+
mavenCentral()
710
}
811

912
dependencies {
1013
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
1114
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
12-
}
15+
implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0")
16+
}

buildSrc/src/main/kotlin/llama-stack-client.java.gradle.kts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import com.diffplug.gradle.spotless.SpotlessExtension
22
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
3-
import java.util.Locale
3+
import com.vanniktech.maven.publish.JavaLibrary
4+
import com.vanniktech.maven.publish.JavadocJar
5+
import com.vanniktech.maven.publish.MavenPublishBaseExtension
6+
import com.vanniktech.maven.publish.SonatypeHost
47

58
plugins {
69
`java-library`
@@ -11,11 +14,6 @@ repositories {
1114
mavenCentral()
1215
}
1316

14-
configure<JavaPluginExtension> {
15-
withJavadocJar()
16-
withSourcesJar()
17-
}
18-
1917
configure<SpotlessExtension> {
2018
java {
2119
importOrder()
@@ -36,10 +34,6 @@ tasks.withType<JavaCompile>().configureEach {
3634
options.release.set(8)
3735
}
3836

39-
tasks.named<Jar>("javadocJar") {
40-
setZip64(true)
41-
}
42-
4337
tasks.named<Jar>("jar") {
4438
manifest {
4539
attributes(mapOf(
@@ -55,4 +49,4 @@ tasks.named<Test>("test") {
5549
testLogging {
5650
exceptionFormat = TestExceptionFormat.FULL
5751
}
58-
}
52+
}

buildSrc/src/main/kotlin/llama-stack-client.kotlin.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import com.diffplug.gradle.spotless.SpotlessExtension
22
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
import com.vanniktech.maven.publish.*
34

45
plugins {
56
id("llama-stack-client.java")
@@ -25,4 +26,4 @@ tasks.withType<KotlinCompile>().configureEach {
2526
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=1.8")
2627
jvmTarget = "1.8"
2728
}
28-
}
29+
}

buildSrc/src/main/kotlin/llama-stack-client.publish.gradle.kts

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,52 @@ import org.gradle.api.publish.maven.MavenPublication
33
import org.gradle.kotlin.dsl.configure
44
import org.gradle.kotlin.dsl.register
55
import org.gradle.kotlin.dsl.get
6+
import com.vanniktech.maven.publish.JavaLibrary
7+
import com.vanniktech.maven.publish.JavadocJar
8+
import com.vanniktech.maven.publish.MavenPublishBaseExtension
9+
import com.vanniktech.maven.publish.SonatypeHost
610

711
plugins {
8-
`maven-publish`
9-
`signing`
12+
id("com.vanniktech.maven.publish")
1013
}
1114

12-
configure<PublishingExtension> {
13-
publications {
14-
register<MavenPublication>("maven") {
15-
from(components["java"])
15+
repositories {
16+
gradlePluginPortal()
17+
mavenCentral()
18+
}
1619

17-
pom {
18-
name.set("[DRAFT] Llama Stack Specification")
19-
description.set("This is the specification of the llama stack that provides a set of endpoints\nand their corresponding interfaces that are tailored to best leverage Llama\nModels. The specification is still in draft and subject to change. Generated at\n2024-11-12 11:16:58.657871")
20-
url.set("https://llama-stack.readthedocs.io/en/latest/")
20+
extra["signingInMemoryKey"] = System.getenv("GPG_SIGNING_KEY")
21+
extra["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID")
22+
extra["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD")
2123

22-
licenses {
23-
license {
24-
name.set("Apache-2.0")
25-
}
26-
}
24+
configure<MavenPublishBaseExtension> {
25+
signAllPublications()
26+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
2727

28-
developers {
29-
developer {
30-
name.set("Llama Stack Client")
31-
email.set("llamastack@meta.com")
32-
}
33-
}
28+
this.coordinates(project.group.toString(), project.name, project.version.toString())
3429

35-
scm {
36-
connection.set("scm:git:git://github.com/stainless-sdks/llama-stack-kotlin.git")
37-
developerConnection.set("scm:git:git://github.com/stainless-sdks/llama-stack-kotlin.git")
38-
url.set("https://github.com/stainless-sdks/llama-stack-kotlin")
39-
}
30+
pom {
31+
name.set("Llama Stack Specification")
32+
description.set("This is the specification of the llama stack that provides a set of endpoints\nand their corresponding interfaces that are tailored to best leverage Llama\nModels. The specification is still in draft and subject to change.")
33+
url.set("https://llama-stack.readthedocs.io/en/latest/")
4034

41-
versionMapping {
42-
allVariants {
43-
fromResolutionResult()
44-
}
45-
}
35+
licenses {
36+
license {
37+
name.set("MIT")
4638
}
4739
}
48-
}
49-
}
5040

51-
signing {
52-
val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null }
53-
val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null }
54-
val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null }
55-
if (signingKey != null && signingPassword != null) {
56-
useInMemoryPgpKeys(
57-
signingKeyId,
58-
signingKey,
59-
signingPassword,
60-
)
61-
sign(publishing.publications["maven"])
62-
}
63-
}
41+
developers {
42+
developer {
43+
name.set("Llama Stack Client")
44+
email.set("llamastack@meta.com")
45+
}
46+
}
6447

65-
tasks.named("publish") {
66-
dependsOn(":closeAndReleaseSonatypeStagingRepository")
67-
}
48+
scm {
49+
connection.set("scm:git:git://github.com/stainless-sdks/llama-stack-kotlin.git")
50+
developerConnection.set("scm:git:git://github.com/stainless-sdks/llama-stack-kotlin.git")
51+
url.set("https://github.com/stainless-sdks/llama-stack-kotlin")
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)