@@ -6,7 +6,7 @@ buildscript {
66
77plugins {
88 id " fabric-loom" version " ${ loom_version} "
9- id " com.diffplug.spotless" version " 8.0 .0"
9+ id " com.diffplug.spotless" version " 8.1 .0"
1010}
1111
1212def ENV = System . getenv()
@@ -339,60 +339,3 @@ task closeMilestone {
339339 }
340340 }
341341}
342-
343- task uploadBackups {
344- dependsOn build
345-
346- onlyIf {
347- ENV . WI_BACKUPS_API_KEY
348- }
349-
350- doLast {
351- def shortVersion = getGhVersion(). substring(1 )
352- def backupUrl = " https://api.wurstclient.net/artifact-backups/Wurst/${ shortVersion} "
353-
354- def maxRetries = 3
355- def retryCount = 0
356- def success = false
357-
358- while (! success && retryCount < maxRetries) {
359- try {
360- def connection = new URL (backupUrl). openConnection() as HttpURLConnection
361- def boundary = UUID . randomUUID(). toString()
362- connection. setRequestMethod(" POST" )
363- connection. setRequestProperty(" X-API-Key" , ENV . WI_BACKUPS_API_KEY )
364- connection. setRequestProperty(" Accept" , " application/json" )
365- connection. setRequestProperty(" Content-Type" , " multipart/form-data; boundary=$boundary " )
366- connection. doOutput = true
367-
368- def output = connection. outputStream
369- [remapJar, remapSourcesJar]. each { jarTask ->
370- def file = jarTask. archiveFile. get(). asFile
371- output << " --${ boundary} \r\n "
372- output << " Content-Disposition: form-data; name=\" files\" ; filename=\" ${ file.name} \"\r\n "
373- output << " Content-Type: application/java-archive\r\n\r\n "
374- file. withInputStream { input ->
375- output << input
376- }
377- output << " \r\n "
378- }
379- output << " --${ boundary} --\r\n "
380- output. flush()
381-
382- if (connection. responseCode != 200 ) {
383- throw new IOException (" HTTP ${ connection.responseCode} : ${ connection.responseMessage} " )
384- }
385-
386- success = true
387-
388- } catch (Exception e) {
389- retryCount++
390- if (retryCount >= maxRetries) {
391- throw new GradleException (" Failed to upload backups after ${ maxRetries} attempts: ${ e.message} " )
392- }
393- println " Upload attempt ${ retryCount} failed: ${ e.message} . Retrying in 5 seconds..."
394- Thread . sleep(5000 )
395- }
396- }
397- }
398- }
0 commit comments