Skip to content
Permalink
Browse files
upgrade from httpbuilder -> httpbuilder-ng
  • Loading branch information
paulk-asert committed Dec 22, 2020
1 parent d84cc2c commit 3147e92ed905bf3ec6312321faaa00abba7298c3
Showing 5 changed files with 197 additions and 125 deletions.
@@ -66,7 +66,7 @@ buildscript {
dependencies {
classpath "org.ajoberstar:grgit:${getProperty('version.grgit')}"
classpath "at.bxm.gradleplugins:gradle-svntools-plugin:${getProperty('version.svntools')}"
classpath "org.codehaus.groovy.modules.http-builder:http-builder:${getProperty('version.httpbuilder')}"
classpath "io.github.http-builder-ng:http-builder-ng-okhttp:${getProperty('version.httpbuilderng')}"
classpath "org.hidetake:gradle-ssh-plugin:${getProperty('version.sshplugin')}"
classpath "gradle.plugin.io.sdkman:gradle-sdkvendor-plugin:${getProperty('version.sdkmanplugin')}"
}
@@ -94,12 +94,14 @@ ext {
if (releaseBuild) {
def parts = relVersion?.split(/\./)
baseVersion = parts?.with{ "${it[0]}.${it[1]}.0" }
if (stableBuild) {
nextVersion = [parts[0], parts[1], parts[2].toInteger() + 1].join('.')
} else {
def subparts = parts[2]?.split(/-/)
def part2 = [subparts[0], subparts[1], subparts[2].toInteger() + 1].join('-')
nextVersion = [parts[0], parts[1], part2].join('.')
if (parts) {
if (stableBuild) {
nextVersion = [parts[0], parts[1], parts[2].toInteger() + 1].join('.')
} else {
def subparts = parts[2]?.split(/-/)
def part2 = [subparts[0], subparts[1], subparts[2].toInteger() + 1].join('-')
nextVersion = [parts[0], parts[1], part2].join('.')
}
}
}
devWorkspaceRoot = "$project.buildDir/svn-dev-workspace-$branch"
@@ -1,5 +1,5 @@
version.grgit=2.3.0
version.svntools=2.2.1
version.httpbuilder=0.7.1
version.httpbuilderng=1.0.4
version.sshplugin=2.7.0
version.sdkmanplugin=1.1.1
@@ -1,10 +1,8 @@
import groovyx.net.http.RESTClient
import groovyx.net.http.HttpBuilder
import org.ajoberstar.grgit.Credentials
import org.ajoberstar.grgit.util.JGitUtil
import org.apache.tools.ant.taskdefs.condition.Os

import static groovyx.net.http.ContentType.JSON

buildscript {
repositories {
jcenter()
@@ -16,7 +14,7 @@ buildscript {
dependencies {
classpath "org.ajoberstar:grgit:${getProperty('version.grgit')}"
classpath "at.bxm.gradleplugins:gradle-svntools-plugin:${getProperty('version.svntools')}"
classpath "org.codehaus.groovy.modules.http-builder:http-builder:${getProperty('version.httpbuilder')}"
classpath "io.github.http-builder-ng:http-builder-ng-okhttp:${getProperty('version.httpbuilderng')}"
classpath "org.hidetake:gradle-ssh-plugin:${getProperty('version.sshplugin')}"
classpath "gradle.plugin.io.sdkman:gradle-sdkvendor-plugin:${getProperty('version.sdkmanplugin')}"
}
@@ -92,14 +90,14 @@ task untagVersion(dependsOn: assumesPropsSet) {
task unreleaseOnJira(dependsOn: jiraCheckPhase2) {
description = "Unrelease on Jira if the VOTE is cancelled"
doLast {
def jira = new RESTClient('https://issues.apache.org/jira/rest/api/2/')
jira.headers['Authorization'] = 'Basic ' + "$apacheUser:$apachePassword".getBytes('iso-8859-1').encodeBase64()
def resp = jira.put(
path: "version/$versionId",
body: /{ "released": false, "releaseDate": null }/,
requestContentType: JSON
)
assert resp.status == 200
HttpBuilder.configure {
request.uri = 'https://issues.apache.org'
request.auth.basic apacheUser, apachePassword
}.put {
request.uri.path = "/jira/rest/api/2/version/$versionId"
request.body = /{ "released": false, "releaseDate": null }/
request.contentType = 'application/json'
}
}
}

@@ -3,14 +3,12 @@ import at.bxm.gradleplugins.svntools.tasks.SvnAdd
import at.bxm.gradleplugins.svntools.tasks.SvnCheckout
import at.bxm.gradleplugins.svntools.tasks.SvnCommit
import at.bxm.gradleplugins.svntools.tasks.SvnVersion
import groovyx.net.http.RESTClient
import groovyx.net.http.HttpBuilder
import org.ajoberstar.grgit.Credentials
import org.ajoberstar.grgit.Person
import org.ajoberstar.grgit.util.JGitUtil
import org.apache.tools.ant.taskdefs.condition.Os

import static groovyx.net.http.ContentType.JSON

buildscript {
repositories {
jcenter()
@@ -22,7 +20,7 @@ buildscript {
dependencies {
classpath "org.ajoberstar:grgit:${getProperty('version.grgit')}"
classpath "at.bxm.gradleplugins:gradle-svntools-plugin:${getProperty('version.svntools')}"
classpath "org.codehaus.groovy.modules.http-builder:http-builder:${getProperty('version.httpbuilder')}"
classpath "io.github.http-builder-ng:http-builder-ng-okhttp:${getProperty('version.httpbuilderng')}"
classpath "org.hidetake:gradle-ssh-plugin:${getProperty('version.sshplugin')}"
classpath "gradle.plugin.io.sdkman:gradle-sdkvendor-plugin:${getProperty('version.sdkmanplugin')}"
}
@@ -85,25 +83,32 @@ task checkCompatibility(type: Exec, dependsOn: [assumesBranch, checkout]) {

task jiraPrecheck(dependsOn: assumesRelVersion) {
doLast {
def jira = new RESTClient('https://issues.apache.org/jira/rest/api/2/')
def resp = jira.get(path: 'project/GROOVY/versions')
assert resp.status == 200 && resp.data
def versionFields = resp.data.find { it.name == relVersion }
def prefix = '/jira/rest/api/2'
def jira = HttpBuilder.configure {
request.uri = 'https://issues.apache.org'
request.auth.basic apacheUser, apachePassword
}
def resp = jira.get {
request.uri.path = "$prefix/project/GROOVY/versions"
}
def versionFields = resp.find { it.name == relVersion }
assert versionFields, "Version $relVersion not found in Jira!"
if (!project.hasProperty('skipJiraReleaseCheck')) {
assert !versionFields.released, "Version $relVersion already released!"
}
project.ext.versionId = versionFields.id
project.ext.projectId = versionFields.projectId

resp = jira.get(path: "version/$versionId/unresolvedIssueCount")
assert resp.status == 200 && resp.data
if (resp.data.issuesUnresolvedCount) {
logger.warn "Warning found $resp.data.issuesUnresolvedCount unresolved issues for version $relVersion"
resp = jira.get {
request.uri.path = "$prefix/version/$versionId/unresolvedIssueCount"
}
resp = jira.get(path: "version/$versionId/relatedIssueCounts")
assert resp.status == 200 && resp.data
project.ext.fixCount = resp.data.issuesFixedCount
if (resp.issuesUnresolvedCount) {
logger.warn "Warning found $resp.issuesUnresolvedCount unresolved issues for version $relVersion"
}
resp = jira.get {
request.uri.path = "$prefix/version/$versionId/relatedIssueCounts"
}
project.ext.fixCount = resp.issuesFixedCount
}
}

@@ -151,7 +156,7 @@ task buildAndUploadStep1(type: Exec, dependsOn: [assumesPropsSet, updateVersionP
if (project.hasProperty('useAntlr4')) {
theArgs << "-PuseAntlr4=${getProperty('useAntlr4')}"
}
if (!relVersion.startsWith('2.4')) {
if (!relVersion?.startsWith('2.4')) {
theArgs << '--no-build-cache'
}
theArgs << "-PartifactoryContext=https://groovy.jfrog.io/groovy/"
@@ -272,14 +277,14 @@ task releaseOnJira(dependsOn: [assumesRelVersion, jiraPrecheck, createAndPushTag
group = "Pre-vote phase"
description = "Releases the version on JIRA"
doLast {
def jira = new RESTClient('https://issues.apache.org/jira/rest/api/2/')
jira.headers['Authorization'] = 'Basic ' + "$apacheUser:$apachePassword".getBytes('iso-8859-1').encodeBase64()
def resp = jira.put(
path: "version/$versionId",
body: /{ "released": true, "releaseDate": "$now" }/,
requestContentType: JSON
)
assert resp.status == 200
HttpBuilder.configure {
request.uri = 'https://issues.apache.org'
request.auth.basic apacheUser, apachePassword
}.put {
request.uri.path = "/jira/rest/api/2/version/$versionId"
request.body = /{ "released": true, "releaseDate": "$now" }/
request.contentType = 'application/json'
}
}
}

0 comments on commit 3147e92

Please sign in to comment.