Skip to content

Commit 1a1458c

Browse files
feat(api): update via SDK Studio (#27)
1 parent d27141e commit 1a1458c

File tree

14 files changed

+72
-108
lines changed

14 files changed

+72
-108
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ jobs:
3535
- name: Run lints
3636
run: ./scripts/lint
3737

38+

.github/workflows/publish-sonatype.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
- name: Publish to Sonatype
3232
run: |
33-
./gradlew --parallel --no-daemon publish
33+
./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD"
3434
env:
3535
SONATYPE_USERNAME: ${{ secrets.OPENLAYER_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
3636
SONATYPE_PASSWORD: ${{ secrets.OPENLAYER_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}

build.gradle.kts

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
plugins {
2-
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
2+
33
}
44

55
allprojects {
66
group = "com.openlayer.api"
77
version = "0.1.0-alpha.1" // x-release-please-version
88
}
99

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/"))
1510

16-
username.set(System.getenv("SONATYPE_USERNAME"))
17-
password.set(System.getenv("SONATYPE_PASSWORD"))
18-
}
19-
}
20-
}

buildSrc/build.gradle.kts

+4
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")
15+
implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0")
1216
}

buildSrc/src/main/kotlin/openlayer.java.gradle.kts

+4-10
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()
@@ -35,10 +33,6 @@ tasks.withType<JavaCompile>().configureEach {
3533
options.release.set(8)
3634
}
3735

38-
tasks.named<Jar>("javadocJar") {
39-
setZip64(true)
40-
}
41-
4236
tasks.named<Jar>("jar") {
4337
manifest {
4438
attributes(mapOf(

buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts

+1
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("openlayer.java")

buildSrc/src/main/kotlin/openlayer.publish.gradle.kts

+35-48
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("Openlayer API")
19-
description.set("API for interacting with the Openlayer server.")
20-
url.set("https://openlayer.com/docs/api-reference/rest/overview")
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("Openlayer")
31-
email.set("[email protected]")
32-
}
33-
}
28+
this.coordinates(project.group.toString(), project.name, project.version.toString())
3429

35-
scm {
36-
connection.set("scm:git:git://github.com/openlayer-ai/openlayer-java.git")
37-
developerConnection.set("scm:git:git://github.com/openlayer-ai/openlayer-java.git")
38-
url.set("https://github.com/openlayer-ai/openlayer-java")
39-
}
30+
pom {
31+
name.set("Openlayer API")
32+
description.set("API for interacting with the Openlayer server.")
33+
url.set("https://openlayer.com/docs/api-reference/rest/overview")
4034

41-
versionMapping {
42-
allVariants {
43-
fromResolutionResult()
44-
}
45-
}
35+
licenses {
36+
license {
37+
name.set("Apache-2.0")
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("Openlayer")
44+
email.set("[email protected]")
45+
}
46+
}
6447

65-
tasks.named("publish") {
66-
dependsOn(":closeAndReleaseSonatypeStagingRepository")
48+
scm {
49+
connection.set("scm:git:git://github.com/openlayer-ai/openlayer-java.git")
50+
developerConnection.set("scm:git:git://github.com/openlayer-ai/openlayer-java.git")
51+
url.set("https://github.com/openlayer-ai/openlayer-java")
52+
}
53+
}
6754
}

openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/BinaryResponseContent.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package com.openlayer.api.core.http
22

3-
import java.io.Closeable
43
import java.io.IOException
54
import java.io.InputStream
65
import java.io.OutputStream
6+
import java.lang.AutoCloseable
7+
import java.util.Optional
78

8-
interface BinaryResponseContent : Closeable {
9+
interface BinaryResponseContent : AutoCloseable {
910

10-
fun contentType(): String?
11+
fun contentType(): Optional<String>
1112

1213
fun body(): InputStream
1314

openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpClient.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.openlayer.api.core.http
22

33
import com.openlayer.api.core.RequestOptions
4-
import java.io.Closeable
4+
import java.lang.AutoCloseable
55
import java.util.concurrent.CompletableFuture
66

7-
interface HttpClient : Closeable {
7+
interface HttpClient : AutoCloseable {
88

99
fun execute(
1010
request: HttpRequest,

openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequestBody.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.openlayer.api.core.http
22

3-
import java.io.Closeable
43
import java.io.IOException
54
import java.io.OutputStream
5+
import java.lang.AutoCloseable
66

7-
interface HttpRequestBody : Closeable {
7+
interface HttpRequestBody : AutoCloseable {
88

99
@Throws(IOException::class) fun writeTo(outputStream: OutputStream)
1010

openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpResponse.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.openlayer.api.core.http
22

33
import com.google.common.collect.ListMultimap
4-
import java.io.Closeable
54
import java.io.InputStream
5+
import java.lang.AutoCloseable
66

7-
interface HttpResponse : Closeable {
7+
interface HttpResponse : AutoCloseable {
88

99
fun statusCode(): Int
1010

openlayer-java-core/src/main/kotlin/com/openlayer/api/services/Handlers.kt

+13-22
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import com.openlayer.api.errors.UnexpectedStatusCodeException
1919
import com.openlayer.api.errors.UnprocessableEntityException
2020
import java.io.InputStream
2121
import java.io.OutputStream
22+
import java.util.Optional
2223

2324
@JvmSynthetic internal fun emptyHandler(): Handler<Void?> = EmptyHandler
2425

@@ -38,7 +39,18 @@ private object StringHandler : Handler<String> {
3839

3940
private object BinaryHandler : Handler<BinaryResponseContent> {
4041
override fun handle(response: HttpResponse): BinaryResponseContent {
41-
return BinaryResponseContentImpl(response)
42+
return object : BinaryResponseContent {
43+
override fun contentType(): Optional<String> =
44+
Optional.ofNullable(response.headers().get("Content-Type").firstOrNull())
45+
46+
override fun body(): InputStream = response.body()
47+
48+
override fun close() = response.close()
49+
50+
override fun writeTo(outputStream: OutputStream) {
51+
response.body().copyTo(outputStream)
52+
}
53+
}
4254
}
4355
}
4456

@@ -107,24 +119,3 @@ internal fun <T> Handler<T>.withErrorHandler(errorHandler: Handler<OpenlayerErro
107119
}
108120
}
109121
}
110-
111-
class BinaryResponseContentImpl
112-
constructor(
113-
private val response: HttpResponse,
114-
) : BinaryResponseContent {
115-
override fun contentType(): String? {
116-
return response.headers().get("Content-Type").firstOrNull()
117-
}
118-
119-
override fun body(): InputStream {
120-
return response.body()
121-
}
122-
123-
override fun writeTo(outputStream: OutputStream) {
124-
response.body().copyTo(outputStream)
125-
}
126-
127-
override fun close() {
128-
response.body().close()
129-
}
130-
}

openlayer-java-core/src/test/kotlin/com/openlayer/api/client/OpenlayerClientTest.kt

-5
This file was deleted.

scripts/mock

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"
2121

2222
# Run prism mock on the given spec
2323
if [ "$1" == "--daemon" ]; then
24-
npm exec --package=@stainless-api/[email protected].4 -- prism mock "$URL" &> .prism.log &
24+
npm exec --package=@stainless-api/[email protected].5 -- prism mock "$URL" &> .prism.log &
2525

2626
# Wait for server to come online
2727
echo -n "Waiting for server"
@@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then
3737

3838
echo
3939
else
40-
npm exec --package=@stainless-api/[email protected].4 -- prism mock "$URL"
40+
npm exec --package=@stainless-api/[email protected].5 -- prism mock "$URL"
4141
fi

0 commit comments

Comments
 (0)