Skip to content

Commit e6784cc

Browse files
Now it MUST work
1 parent aa928dd commit e6784cc

1 file changed

Lines changed: 41 additions & 12 deletions

File tree

build.gradle

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ tasks.register('publishToMavenCentral') {
104104
println "Uploading bundle to Maven Central Portal..."
105105
println "Bundle file: ${bundleFile.absolutePath} (${bundleFile.length()} bytes)"
106106
println "Token length: ${token.length()} characters"
107+
println "Token starts with: ${token.take(15)}..."
108+
println "Token ends with: ...${token.takeRight(15)}"
107109

108110
// Create a temporary file to capture the response
109111
def responseFile = File.createTempFile("maven-central-response", ".json")
@@ -112,10 +114,13 @@ tasks.register('publishToMavenCentral') {
112114
// Build the authorization header separately to avoid interpolation issues
113115
def authHeader = "Authorization: Bearer ${token}"
114116

117+
println "Running curl command..."
118+
115119
def process = [
116120
'curl', '-X', 'POST',
117121
'--fail-with-body',
118-
'-w', '\n%{http_code}',
122+
'-s', // silent mode to suppress progress
123+
'-w', '\nHTTP_CODE:%{http_code}',
119124
'-o', responseFile.absolutePath,
120125
'-H', authHeader,
121126
'-F', "bundle=@${bundleFile.absolutePath}",
@@ -127,27 +132,50 @@ tasks.register('publishToMavenCentral') {
127132
process.waitForProcessOutput(output, error)
128133
def exitCode = process.exitValue()
129134

135+
println "Curl exit code: ${exitCode}"
136+
println "Curl stdout: ${output.toString()}"
137+
println "Curl stderr: ${error.toString()}"
138+
130139
// Read the response
131-
def response = responseFile.text
132-
def httpCode = output.toString().trim().split('\n').last()
140+
def response = responseFile.exists() ? responseFile.text : ""
141+
println "Response file exists: ${responseFile.exists()}"
142+
println "Response file size: ${responseFile.exists() ? responseFile.length() : 0} bytes"
143+
println "Response content: '${response}'"
133144

134-
println "HTTP Status: ${httpCode}"
135-
println "Response: ${response}"
145+
// Extract HTTP code
146+
def httpCode = "UNKNOWN"
147+
def outputStr = output.toString()
148+
if (outputStr.contains('HTTP_CODE:')) {
149+
httpCode = outputStr.split('HTTP_CODE:')[1].trim()
150+
}
136151

137-
// Check for errors in response
138-
if (exitCode != 0 || response.contains('"error"')) {
139-
def errorMsg = "Failed to upload bundle to Maven Central.\n"
152+
println "Extracted HTTP Status: ${httpCode}"
153+
154+
// Check for errors - be explicit about what we're checking
155+
def hasError = response.contains('"error"') || response.contains('error')
156+
def isSuccessCode = httpCode == '201' || httpCode == '200'
157+
158+
println "Response contains 'error': ${hasError}"
159+
println "HTTP code is success (200/201): ${isSuccessCode}"
160+
161+
if (exitCode != 0 || hasError || !isSuccessCode) {
162+
def errorMsg = "\n" + "="*80 + "\n"
163+
errorMsg += "❌ UPLOAD FAILED\n"
164+
errorMsg += "="*80 + "\n"
140165
errorMsg += "Exit code: ${exitCode}\n"
141166
errorMsg += "HTTP Status: ${httpCode}\n"
142167
errorMsg += "Response: ${response}\n"
143168
if (error.length() > 0) {
144-
errorMsg += "Error output: ${error.toString()}"
169+
errorMsg += "Curl stderr: ${error.toString()}\n"
145170
}
171+
errorMsg += "="*80 + "\n"
146172
throw new GradleException(errorMsg)
147173
}
148174

149-
println "Bundle uploaded successfully!"
150-
println "Response: ${response}"
175+
println "="*80
176+
println "✅ Bundle uploaded successfully!"
177+
println "="*80
178+
println "Deployment ID: ${response}"
151179
}
152180
}
153181

@@ -165,7 +193,8 @@ tasks.register('testMavenCentralAuth') {
165193

166194
println "Testing Maven Central Portal authentication..."
167195
println "Token length: ${token.length()} characters"
168-
println "Token starts with: ${token.take(10)}..."
196+
println "Token starts with: ${token.take(15)}..."
197+
println "Token ends with: ...${token.takeRight(15)}"
169198

170199
// Test with a simple GET request to check authentication
171200
// Using the deployments list endpoint which is known to work

0 commit comments

Comments
 (0)