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
9 changes: 7 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 @@ -2,10 +2,10 @@ package nmcp.internal.task

import kotlinx.serialization.Serializable
import kotlinx.serialization.StringFormat
import nl.adaptivity.xmlutil.serialization.XML
import nl.adaptivity.xmlutil.XmlDeclMode
import nl.adaptivity.xmlutil.core.XmlVersion
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 @@ -84,4 +84,9 @@ internal data class ArtifactMetadata(

internal val xml: StringFormat = XML1_0.recommended {
indentString = " "
// Maven Central doesn't understand XML 1.1
// See also https://github.com/pdvrieze/xmlutil/issues/324
xmlVersion = XmlVersion.XML10
// Also set the charset explicitly
xmlDeclMode = XmlDeclMode.Charset
}
37 changes: 15 additions & 22 deletions nmcp-tasks/src/main/kotlin/nmcp/transport/transport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ internal class HttpTransport(
response.close()
return null
}
if(!response.isSuccessful) {
if (!response.isSuccessful) {
response.close()
error("Nmcp: cannot GET '$url' (statusCode=${response.code}):\n${response.body.string()}")
}
Expand All @@ -127,31 +127,24 @@ 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()}'")
when (response.code) {
400 -> {
appendLine("Things to double check:")
appendLine("Your artifacts have proper extensions (.jar, .pom, ...).")
appendLine("If publishing a XML file, the XML version is 1.0.")
appendLine("If publishing a snapshot, the artifacts version is ending with `-SNAPSHOT`.")
}
401 -> {
appendLine("Check your credentials")
appendLine("If publishing a snapshot, make sure you enabled snapshots on your namespace at https://central.sonatype.com/publishing/namespaces.")
}
403 -> {
appendLine("Check that you are publishing to the correct groupId.")
}
429 -> {
appendLine("Too many requests, try again later")
}
else -> {
appendLine("Things to double check:")
/**
* I have seen 401 for this
*/
appendLine(" - Are your credentials correct?")
appendLine(" - Did you enable the snapshots on your namespace at https://central.sonatype.com/publishing/namespaces?")
/**
* I have seen 400 for this
*/
appendLine(" - Is your version ending with `-SNAPSHOT`?")
/**
* I have seen 400 for this.
*/
appendLine(" - Do your artifacts have proper extensions (.jar, .pom, ...)?")
/**
* I have seen 403 for this.
*/
appendLine(" - Is your groupId correct?")
}
}
}
}
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,7 +45,7 @@ class MetadataTest {
*/
// language=xml
val xmlData = """
<?xml version='1.1' ?>
<?xml version='1.0' encoding='UTF-8' ?>
<metadata modelVersion="1.1.0">
<groupId>com.apollographql.apollo</groupId>
<artifactId>apollo-api-jvm</artifactId>
Expand Down Expand Up @@ -111,7 +111,7 @@ class MetadataTest {
fun versionMetadataIsEncodedSuccessfully() {
// language=xml
val xmlData = """
<?xml version='1.1' ?>
<?xml version='1.0' encoding='UTF-8' ?>
<metadata modelVersion="1.1.0">
<groupId>com.apollographql.apollo</groupId>
<artifactId>apollo-api-jvm</artifactId>
Expand Down Expand Up @@ -178,7 +178,7 @@ class MetadataTest {

val result = encodeToXml(metadata)

assertEquals(xmlData, result,)
assertEquals(xmlData, result)
}

@Test
Expand Down