diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 4fb6259..d001aa5 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -33,7 +33,7 @@ jobs: export -- GPG_SIGNING_KEY_ID printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publish --no-configuration-cache + ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache env: SONATYPE_USERNAME: ${{ secrets.LLAMA_CLOUD_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.LLAMA_CLOUD_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} diff --git a/build.gradle.kts b/build.gradle.kts index 5f5e899..538ea70 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - id("io.github.gradle-nexus.publish-plugin") version "1.1.0" id("org.jetbrains.dokka") version "2.0.0" } @@ -34,15 +33,3 @@ tasks.named("dokkaJavadocCollector").configure { .filter { it.project.name != "llama-cloud" && it.name == "dokkaJavadocJar" } .forEach { mustRunAfter(it) } } - -nexusPublishing { - repositories { - sonatype { - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - - username.set(System.getenv("SONATYPE_USERNAME")) - password.set(System.getenv("SONATYPE_PASSWORD")) - } - } -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 0b14135..c6dc92e 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,12 +1,15 @@ plugins { `kotlin-dsl` kotlin("jvm") version "1.9.20" + id("com.vanniktech.maven.publish") version "0.28.0" } repositories { gradlePluginPortal() + mavenCentral() } dependencies { implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") + implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0") } diff --git a/buildSrc/src/main/kotlin/llama-cloud.java.gradle.kts b/buildSrc/src/main/kotlin/llama-cloud.java.gradle.kts index a3cfe28..8f4f902 100644 --- a/buildSrc/src/main/kotlin/llama-cloud.java.gradle.kts +++ b/buildSrc/src/main/kotlin/llama-cloud.java.gradle.kts @@ -8,11 +8,6 @@ repositories { mavenCentral() } -configure { - withJavadocJar() - withSourcesJar() -} - java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) @@ -27,10 +22,6 @@ tasks.withType().configureEach { options.release.set(8) } -tasks.named("javadocJar") { - setZip64(true) -} - tasks.named("jar") { manifest { attributes(mapOf( diff --git a/buildSrc/src/main/kotlin/llama-cloud.publish.gradle.kts b/buildSrc/src/main/kotlin/llama-cloud.publish.gradle.kts index 5a832fd..cc436df 100644 --- a/buildSrc/src/main/kotlin/llama-cloud.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/llama-cloud.publish.gradle.kts @@ -1,68 +1,71 @@ +import com.vanniktech.maven.publish.JavadocJar +import com.vanniktech.maven.publish.KotlinJvm +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.SonatypeHost + plugins { - `maven-publish` - signing + id("com.vanniktech.maven.publish") +} + +publishing { + repositories { + if (project.hasProperty("publishLocal")) { + maven { + name = "LocalFileSystem" + url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo") + } + } + } } -configure { - publications { - register("maven") { - from(components["java"]) +repositories { + gradlePluginPortal() + mavenCentral() +} - pom { - name.set("Llama Platform") - description.set("An SDK library for llama-cloud") - url.set("https://developers.llamaindex.ai/") +extra["signingInMemoryKey"] = System.getenv("GPG_SIGNING_KEY") +extra["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID") +extra["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD") - licenses { - license { - name.set("MIT") - } - } +configure { + if (!project.hasProperty("publishLocal")) { + signAllPublications() + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + } - developers { - developer { - name.set("Llama Cloud") - } - } + coordinates(project.group.toString(), project.name, project.version.toString()) + configure( + KotlinJvm( + javadocJar = JavadocJar.Dokka("dokkaJavadoc"), + sourcesJar = true, + ) + ) - scm { - connection.set("scm:git:git://github.com/run-llama/llama-parse-java.git") - developerConnection.set("scm:git:git://github.com/run-llama/llama-parse-java.git") - url.set("https://github.com/run-llama/llama-parse-java") - } + pom { + name.set("Llama Platform") + description.set("An SDK library for llama-cloud") + url.set("https://developers.llamaindex.ai/") - versionMapping { - allVariants { - fromResolutionResult() - } - } + licenses { + license { + name.set("MIT") } } - } - repositories { - if (project.hasProperty("publishLocal")) { - maven { - name = "LocalFileSystem" - url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo") + + developers { + developer { + name.set("Llama Cloud") } } - } -} -signing { - val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null } - val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null } - val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null } - if (signingKey != null && signingPassword != null) { - useInMemoryPgpKeys( - signingKeyId, - signingKey, - signingPassword, - ) - sign(publishing.publications["maven"]) + scm { + connection.set("scm:git:git://github.com/run-llama/llama-parse-java.git") + developerConnection.set("scm:git:git://github.com/run-llama/llama-parse-java.git") + url.set("https://github.com/run-llama/llama-parse-java") + } } } -tasks.named("publish") { - dependsOn(":closeAndReleaseSonatypeStagingRepository") +tasks.withType().configureEach { + isZip64 = true } diff --git a/llama-cloud-core/src/main/kotlin/com/llamacloud_prod/api/models/beta/directories/DirectoryCreateParams.kt b/llama-cloud-core/src/main/kotlin/com/llamacloud_prod/api/models/beta/directories/DirectoryCreateParams.kt index dd12e61..0a2c99c 100644 --- a/llama-cloud-core/src/main/kotlin/com/llamacloud_prod/api/models/beta/directories/DirectoryCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/com/llamacloud_prod/api/models/beta/directories/DirectoryCreateParams.kt @@ -17,7 +17,6 @@ import com.llamacloud_prod.api.core.http.Headers import com.llamacloud_prod.api.core.http.QueryParams import com.llamacloud_prod.api.core.toImmutable import com.llamacloud_prod.api.errors.LlamaCloudInvalidDataException -import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional @@ -53,14 +52,6 @@ private constructor( */ fun description(): Optional = body.description() - /** - * When this directory expires. Required for ephemeral directories. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expiresAt(): Optional = body.expiresAt() - /** * Reserved system-managed metadata. * @@ -91,13 +82,6 @@ private constructor( */ fun _description(): JsonField = body._description() - /** - * Returns the raw JSON value of [expiresAt]. - * - * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _expiresAt(): JsonField = body._expiresAt() - /** * Returns the raw JSON value of [systemMetadata]. * @@ -171,10 +155,8 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [name] * - [description] - * - [expiresAt] * - [systemMetadata] * - [type] - * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -204,21 +186,6 @@ private constructor( */ fun description(description: JsonField) = apply { body.description(description) } - /** When this directory expires. Required for ephemeral directories. */ - fun expiresAt(expiresAt: OffsetDateTime?) = apply { body.expiresAt(expiresAt) } - - /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ - fun expiresAt(expiresAt: Optional) = expiresAt(expiresAt.getOrNull()) - - /** - * Sets [Builder.expiresAt] to an arbitrary JSON value. - * - * You should usually call [Builder.expiresAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expiresAt(expiresAt: JsonField) = apply { body.expiresAt(expiresAt) } - /** Reserved system-managed metadata. */ fun systemMetadata(systemMetadata: SystemMetadata?) = apply { body.systemMetadata(systemMetadata) @@ -408,7 +375,6 @@ private constructor( private constructor( private val name: JsonField, private val description: JsonField, - private val expiresAt: JsonField, private val systemMetadata: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, @@ -420,14 +386,11 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), - @JsonProperty("expires_at") - @ExcludeMissing - expiresAt: JsonField = JsonMissing.of(), @JsonProperty("system_metadata") @ExcludeMissing systemMetadata: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(name, description, expiresAt, systemMetadata, type, mutableMapOf()) + ) : this(name, description, systemMetadata, type, mutableMapOf()) /** * Human-readable name for the directory. @@ -445,14 +408,6 @@ private constructor( */ fun description(): Optional = description.getOptional("description") - /** - * When this directory expires. Required for ephemeral directories. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun expiresAt(): Optional = expiresAt.getOptional("expires_at") - /** * Reserved system-managed metadata. * @@ -486,15 +441,6 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description - /** - * Returns the raw JSON value of [expiresAt]. - * - * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expires_at") - @ExcludeMissing - fun _expiresAt(): JsonField = expiresAt - /** * Returns the raw JSON value of [systemMetadata]. * @@ -542,7 +488,6 @@ private constructor( private var name: JsonField? = null private var description: JsonField = JsonMissing.of() - private var expiresAt: JsonField = JsonMissing.of() private var systemMetadata: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -551,7 +496,6 @@ private constructor( internal fun from(body: Body) = apply { name = body.name description = body.description - expiresAt = body.expiresAt systemMetadata = body.systemMetadata type = body.type additionalProperties = body.additionalProperties.toMutableMap() @@ -586,23 +530,6 @@ private constructor( this.description = description } - /** When this directory expires. Required for ephemeral directories. */ - fun expiresAt(expiresAt: OffsetDateTime?) = expiresAt(JsonField.ofNullable(expiresAt)) - - /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ - fun expiresAt(expiresAt: Optional) = expiresAt(expiresAt.getOrNull()) - - /** - * Sets [Builder.expiresAt] to an arbitrary JSON value. - * - * You should usually call [Builder.expiresAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expiresAt(expiresAt: JsonField) = apply { - this.expiresAt = expiresAt - } - /** Reserved system-managed metadata. */ fun systemMetadata(systemMetadata: SystemMetadata?) = systemMetadata(JsonField.ofNullable(systemMetadata)) @@ -669,7 +596,6 @@ private constructor( Body( checkRequired("name", name), description, - expiresAt, systemMetadata, type, additionalProperties.toMutableMap(), @@ -694,7 +620,6 @@ private constructor( name() description() - expiresAt() systemMetadata().ifPresent { it.validate() } type().ifPresent { it.validate() } validated = true @@ -718,7 +643,6 @@ private constructor( internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + - (if (expiresAt.asKnown().isPresent) 1 else 0) + (systemMetadata.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) @@ -730,20 +654,19 @@ private constructor( return other is Body && name == other.name && description == other.description && - expiresAt == other.expiresAt && systemMetadata == other.systemMetadata && type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(name, description, expiresAt, systemMetadata, type, additionalProperties) + Objects.hash(name, description, systemMetadata, type, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{name=$name, description=$description, expiresAt=$expiresAt, systemMetadata=$systemMetadata, type=$type, additionalProperties=$additionalProperties}" + "Body{name=$name, description=$description, systemMetadata=$systemMetadata, type=$type, additionalProperties=$additionalProperties}" } /** Reserved system-managed metadata. */ diff --git a/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/models/beta/directories/DirectoryCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/models/beta/directories/DirectoryCreateParamsTest.kt index b8f8fba..737658d 100644 --- a/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/models/beta/directories/DirectoryCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/models/beta/directories/DirectoryCreateParamsTest.kt @@ -4,7 +4,6 @@ package com.llamacloud_prod.api.models.beta.directories import com.llamacloud_prod.api.core.JsonValue import com.llamacloud_prod.api.core.http.QueryParams -import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -17,7 +16,6 @@ internal class DirectoryCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("x") .description("description") - .expiresAt(OffsetDateTime.parse("2026-05-10T00:00:00Z")) .systemMetadata( DirectoryCreateParams.SystemMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) @@ -35,7 +33,6 @@ internal class DirectoryCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("x") .description("description") - .expiresAt(OffsetDateTime.parse("2026-05-10T00:00:00Z")) .systemMetadata( DirectoryCreateParams.SystemMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) @@ -72,7 +69,6 @@ internal class DirectoryCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("x") .description("description") - .expiresAt(OffsetDateTime.parse("2026-05-10T00:00:00Z")) .systemMetadata( DirectoryCreateParams.SystemMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) @@ -85,7 +81,6 @@ internal class DirectoryCreateParamsTest { assertThat(body.name()).isEqualTo("x") assertThat(body.description()).contains("description") - assertThat(body.expiresAt()).contains(OffsetDateTime.parse("2026-05-10T00:00:00Z")) assertThat(body.systemMetadata()) .contains( DirectoryCreateParams.SystemMetadata.builder() diff --git a/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/services/async/beta/DirectoryServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/services/async/beta/DirectoryServiceAsyncTest.kt index c69e3ff..8abe066 100644 --- a/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/services/async/beta/DirectoryServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/services/async/beta/DirectoryServiceAsyncTest.kt @@ -8,7 +8,6 @@ import com.llamacloud_prod.api.models.beta.directories.DirectoryCreateParams import com.llamacloud_prod.api.models.beta.directories.DirectoryDeleteParams import com.llamacloud_prod.api.models.beta.directories.DirectoryGetParams import com.llamacloud_prod.api.models.beta.directories.DirectoryUpdateParams -import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -27,7 +26,6 @@ internal class DirectoryServiceAsyncTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("x") .description("description") - .expiresAt(OffsetDateTime.parse("2026-05-10T00:00:00Z")) .systemMetadata( DirectoryCreateParams.SystemMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) diff --git a/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/services/blocking/beta/DirectoryServiceTest.kt b/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/services/blocking/beta/DirectoryServiceTest.kt index f133a4e..a165f09 100644 --- a/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/services/blocking/beta/DirectoryServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/com/llamacloud_prod/api/services/blocking/beta/DirectoryServiceTest.kt @@ -8,7 +8,6 @@ import com.llamacloud_prod.api.models.beta.directories.DirectoryCreateParams import com.llamacloud_prod.api.models.beta.directories.DirectoryDeleteParams import com.llamacloud_prod.api.models.beta.directories.DirectoryGetParams import com.llamacloud_prod.api.models.beta.directories.DirectoryUpdateParams -import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -27,7 +26,6 @@ internal class DirectoryServiceTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("x") .description("description") - .expiresAt(OffsetDateTime.parse("2026-05-10T00:00:00Z")) .systemMetadata( DirectoryCreateParams.SystemMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar"))