Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/build-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- run: |
./gradlew build
./gradlew -p tests/jvm build
./gradlew -p tests/kmp publishAggregationToCentralPortal --configuration-cache
./gradlew -p tests/kmp build
./scripts/integration-tests.sh
21 changes: 11 additions & 10 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
[versions]
kgp = "2.2.20"
ksp = "2.3.2"
gratatouille-runtime = "0.2.0"
gratatouille-plugin = "0.2.0"
kgp = "2.3.0"
ksp = "2.3.4"
gratatouille-runtime = "0.2.1"
gratatouille-plugin = "0.2.1"

[libraries]
json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1"
okio = "com.squareup.okio:okio:3.8.0"
okhttp = "com.squareup.okhttp3:okhttp:4.12.0"
mockwebserver = "com.squareup.okhttp3:mockwebserver:4.12.0"
json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0"
okio = "com.squareup.okio:okio:3.16.4"
okhttp = "com.squareup.okhttp3:okhttp:5.3.2"
mockwebserver = "com.squareup.okhttp3:mockwebserver:5.3.2"
#noinspection NewerVersionAvailable
gradle-min = "dev.gradleplugins:gradle-api:8.8"
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test" }
xmlutil = "io.github.pdvrieze.xmlutil:serialization:0.91.1"
xmlutil = "io.github.pdvrieze.xmlutil:serialization:1.0.0-rc1"
kgp = { module = "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kgp" }
coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2"
gratatouille-runtime = { module = "com.gradleup.gratatouille:gratatouille-runtime", version.ref = "gratatouille-runtime" }
Expand All @@ -24,4 +25,4 @@ ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
gratatouille = { id = "com.gradleup.gratatouille", version.ref = "gratatouille-plugin" }
librarian = { id = "com.gradleup.librarian", version = "0.2.2-SNAPSHOT-6898196f1f9759091ae6fa9bbe84154ec28a9331" }
nmcp = { id = "com.gradleup.nmcp", version = "1.3.0" }
compat = { id = "com.gradleup.compat.patrouille", version = "0.0.1-SNAPSHOT-9da44b3b93e36a196ae5afc9f7a79a46a82763cd" }
compat = { id = "com.gradleup.tapmoc", version = "0.3.3-SNAPSHOT-a7d9d3fed6e48f1a88966d81e753259dadfa9a9a" }
6 changes: 4 additions & 2 deletions nmcp-tasks/src/main/kotlin/nmcp/internal/task/metadata.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package nmcp.internal.task
import kotlinx.serialization.Serializable
import kotlinx.serialization.StringFormat
import nl.adaptivity.xmlutil.serialization.XML
import nl.adaptivity.xmlutil.serialization.XML1_0
import nl.adaptivity.xmlutil.serialization.XmlChildrenName
import nl.adaptivity.xmlutil.serialization.XmlConfig
import nl.adaptivity.xmlutil.serialization.XmlElement
import nl.adaptivity.xmlutil.serialization.XmlSerialName

Expand Down Expand Up @@ -80,6 +82,6 @@ internal data class ArtifactMetadata(
)
}

internal val xml: StringFormat = XML {
indent = 2
internal val xml: StringFormat = XML1_0.recommended {
indentString = " "
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package nmcp.internal.task

import gratatouille.tasks.GInputFile
import gratatouille.tasks.GInputFiles
import gratatouille.tasks.GLogger
import gratatouille.tasks.GTask
import java.net.SocketTimeoutException
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
Expand All @@ -15,15 +12,12 @@ import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import nmcp.transport.nmcpClient
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.MultipartBody
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.asRequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okio.Buffer
import okio.BufferedSink
import okio.ByteString
import okio.use

Expand Down Expand Up @@ -58,8 +52,10 @@ internal fun nmcpPublishWithPublisherApi(
)
.build()

@Suppress("NAME_SHADOWING")
val publishingType = publishingType ?: "AUTOMATIC"

@Suppress("NAME_SHADOWING")
val baseUrl = baseUrl ?: "https://central.sonatype.com/"
val url = baseUrl + "api/v1/publisher/upload?publishingType=$publishingType"

Expand All @@ -73,10 +69,10 @@ internal fun nmcpPublishWithPublisherApi(
nmcpClient.newCall(it).execute()
}.use {
if (!it.isSuccessful) {
error("Cannot deploy to maven central (status='${it.code}'): ${it.body?.string()}")
error("Cannot deploy to maven central (status='${it.code}'): ${it.body.string()}")
}

it.body!!.string()
it.body.string()
}

logger.lifecycle("Nmcp: deployment bundle '$deploymentId' uploaded.")
Expand Down Expand Up @@ -180,10 +176,10 @@ private fun verifyStatus(
}
}.use {
if (!it.isSuccessful) {
error("Cannot verify deployment $deploymentId status (HTTP status='${it.code}'): ${it.body?.string()}")
error("Cannot verify deployment $deploymentId status (HTTP status='${it.code}'): ${it.body.string()}")
}

val str = it.body!!.string()
val str = it.body.string()
val element = Json.parseToJsonElement(str)
check(element is JsonObject) {
"Nmcp: unexpected status response for deployment $deploymentId: $str"
Expand All @@ -207,32 +203,3 @@ private fun verifyStatus(
}
}
}

internal class ZipBody(val files: GInputFiles, private val logger: GLogger) : RequestBody() {
override fun contentType(): MediaType {
return "application/octet-stream".toMediaType()
}

override fun writeTo(sink: BufferedSink) {
val stream = ZipOutputStream(sink.outputStream())
files.forEach {
if (it.file.isDirectory) {
return@forEach
}
// Exclude maven-metadata files or the bundle is not recognized
// See https://slack-chats.kotlinlang.org/t/16407246/anyone-tried-the-https-central-sonatype-org-publish-publish-#c8738fe5-8051-4f64-809f-ca67a645216e
if (it.file.name.startsWith("maven-metadata")) {
return@forEach
}
logger.info("Nmcp: zip ${it.normalizedPath}")
stream.putNextEntry(ZipEntry(it.normalizedPath))
it.file.inputStream().use {
it.copyTo(stream)
}
stream.closeEntry()
}
stream.finish()
stream.flush()
sink.flush()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,8 @@ internal fun Instant.asTimestamp(withDot: Boolean): String {

internal val checksums = setOf("md5", "sha1", "sha256", "sha512")

/**
* Helper function to add the `<?xml...` preamble as I haven't found how to do it with xmlutils
*/
internal inline fun <reified T> encodeToXml(t: T): String {
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xml.encodeToString(t)
return xml.encodeToString(t)
}

private fun ByteArray.digest(name: String): String {
Expand Down
6 changes: 3 additions & 3 deletions nmcp-tasks/src/main/kotlin/nmcp/transport/transport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ internal class HttpTransport(
}
if(!response.isSuccessful) {
response.close()
error("Nmcp: cannot GET '$url' (statusCode=${response.code}):\n${response.body!!.string()}")
error("Nmcp: cannot GET '$url' (statusCode=${response.code}):\n${response.body.string()}")
}

return response.body!!.source()
return response.body.source()
}

override fun put(path: String, body: Content) {
Expand All @@ -127,7 +127,7 @@ internal class HttpTransport(
check(response.isSuccessful) {
buildString {
appendLine("Nmcp: cannot PUT '$url' (statusCode=${response.code}).")
appendLine("Response body: ${response.body!!.string()}")
appendLine("Response body: ${response.body.string()}")
appendLine("Things to double check:")
/**
* I have seen 401 for this
Expand Down
6 changes: 3 additions & 3 deletions nmcp-tasks/src/test/kotlin/MetadataTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class MetadataTest {
*/
// language=xml
val xmlData = """
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.1' ?>
<metadata modelVersion="1.1.0">
<groupId>com.apollographql.apollo</groupId>
<artifactId>apollo-api-jvm</artifactId>
<versioning>
<latest>5.0.0-SNAPSHOT</latest>
<release></release>
<release />
<versions>
<version>4.1.2-SNAPSHOT</version>
<version>5.0.0-SNAPSHOT</version>
Expand Down Expand Up @@ -111,7 +111,7 @@ class MetadataTest {
fun versionMetadataIsEncodedSuccessfully() {
// language=xml
val xmlData = """
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.1' ?>
<metadata modelVersion="1.1.0">
<groupId>com.apollographql.apollo</groupId>
<artifactId>apollo-api-jvm</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions scripts/integration-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
set -e
set -x
./gradlew -p tests/jvm build
./gradlew -p tests/kmp publishAggregationToCentralPortal --configuration-cache
./gradlew -p tests/kmp build
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pluginManagement {
content {
// gratatouille-processor is only used at build time and is safe to fetch as a snapshot
includeModule("com.gradleup.gratatouille", "gratatouille-processor")
includeModule("com.gradleup.tapmoc", "tapmoc-tasks")
}
}
}
Expand Down
40 changes: 20 additions & 20 deletions tests/kmp/kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ balanced-match@^1.0.0:
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

brace-expansion@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae"
integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==
version "2.0.2"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.2.tgz#54fc53237a613d854c7bd37463aad17df87214e7"
integrity sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==
dependencies:
balanced-match "^1.0.0"

Expand Down Expand Up @@ -119,9 +119,9 @@ cross-spawn@^7.0.6:
which "^2.0.1"

debug@^4.3.5:
version "4.4.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a"
integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==
version "4.4.3"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a"
integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==
dependencies:
ms "^2.1.3"

Expand Down Expand Up @@ -192,9 +192,9 @@ get-caller-file@^2.0.5:
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==

glob@^10.4.5:
version "10.4.5"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956"
integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==
version "10.5.0"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.5.0.tgz#8ec0355919cd3338c28428a23d4f24ecc5fe738c"
integrity sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==
dependencies:
foreground-child "^3.1.0"
jackspeak "^3.1.2"
Expand Down Expand Up @@ -243,16 +243,16 @@ jackspeak@^3.1.2:
"@pkgjs/parseargs" "^0.11.0"

js-yaml@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
version "4.1.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.1.tgz#854c292467705b699476e1a2decc0c8a3458806b"
integrity sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==
dependencies:
argparse "^2.0.1"

kotlin-web-helpers@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/kotlin-web-helpers/-/kotlin-web-helpers-2.1.0.tgz#6cd4b0f0dc3baea163929c8638155b8d19c55a74"
integrity sha512-NAJhiNB84tnvJ5EQx7iER3GWw7rsTZkX9HVHZpe7E3dDBD/dhTzqgSwNU3MfQjniy2rB04bP24WM9Z32ntUWRg==
kotlin-web-helpers@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/kotlin-web-helpers/-/kotlin-web-helpers-3.0.0.tgz#3ed6b48f694f74bb60a737a9d7e2c0e3b29abdb9"
integrity sha512-kdQO4AJQkUPvpLh9aglkXDRyN+CfXO7pKq+GESEnxooBFkQpytLrqZis3ABvmFN1cGw/ZQ/K38u5sRGW+NfBnw==
dependencies:
format-util "^1.0.5"

Expand Down Expand Up @@ -288,10 +288,10 @@ minimatch@^9.0.4, minimatch@^9.0.5:
resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707"
integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==

mocha@11.7.1:
version "11.7.1"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-11.7.1.tgz#91948fecd624fb4bd154ed260b7e1ad3910d7c7a"
integrity sha512-5EK+Cty6KheMS/YLPPMJC64g5V61gIR25KsRItHw6x4hEKT6Njp1n9LOlH4gpevuwMVS66SXaBBpg+RWZkza4A==
mocha@11.7.2:
version "11.7.2"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-11.7.2.tgz#3c0079fe5cc2f8ea86d99124debcc42bb1ab22b5"
integrity sha512-lkqVJPmqqG/w5jmmFtiRvtA2jkDyNVUcefFJKb2uyX4dekk8Okgqop3cgbFiaIvj8uCRJVTP5x9dfxGyXm2jvQ==
dependencies:
browser-stdout "^1.3.1"
chokidar "^4.0.1"
Expand Down