use JDK11 Http client
diff --git a/build.gradle b/build.gradle
index c698703..d16f948 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,4 +1,4 @@
-import org.apache.tools.ant.taskdefs.condition.Os
+//import org.apache.tools.ant.taskdefs.condition.Os
/**
* Phase1 is invoked with:
@@ -54,26 +54,22 @@
* <li>The KEYS file is currently assumed to be updated manually outside this build script</li>
* </ul>
*/
-
buildscript {
repositories {
- jcenter()
- maven {
- url "https://plugins.gradle.org/m2/"
- }
+ mavenCentral()
}
dependencies {
- classpath "org.ajoberstar:grgit:${getProperty('version.grgit')}"
- classpath "at.bxm.gradleplugins:gradle-svntools-plugin:${getProperty('version.svntools')}"
- 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')}"
+ classpath 'javax.xml.bind:jaxb-api:2.3.1'
}
}
+plugins {
+ id 'org.hidetake.ssh' version '2.10.1'
+ id "io.sdkman.vendors" version "1.2.0"
+}
+
ext {
- grgitClass = org.ajoberstar.grgit.Grgit
repoBase = 'https://gitbox.apache.org/repos/asf'
repoUri = "$repoBase/groovy.git"
websiteRepo = 'https://gitbox.apache.org/repos/asf/groovy-website.git'
diff --git a/buildSrc/src/main/groovy/HttpUtil.groovy b/buildSrc/src/main/groovy/HttpUtil.groovy
index 6a83fab..191771d 100644
--- a/buildSrc/src/main/groovy/HttpUtil.groovy
+++ b/buildSrc/src/main/groovy/HttpUtil.groovy
@@ -22,7 +22,15 @@
.build()
}
- static HttpRequest putRequest(url, json, user, password) {
+ static HttpRequest headRequest(url, user, password) {
+ HttpRequest.newBuilder()
+ .uri(new URI(url))
+ .header('Authorization', 'Basic ' + "$user:$password".getBytes('iso-8859-1').encodeBase64())
+ .method("HEAD", HttpRequest.BodyPublishers.noBody())
+ .build()
+ }
+
+ static HttpRequest putRequest(url, String json, user, password) {
def body = HttpRequest.BodyPublishers.ofString(json)
HttpRequest.newBuilder()
.uri(new URI(url))
@@ -32,6 +40,39 @@
.build()
}
+ static HttpRequest postRequest(url, String json, user, password) {
+ def body = HttpRequest.BodyPublishers.ofString(json)
+ HttpRequest.newBuilder()
+ .uri(new URI(url))
+ .header('Authorization', 'Basic ' + "$user:$password".getBytes('iso-8859-1').encodeBase64())
+ .header('Content-Type', 'application/json')
+ .POST(body)
+ .build()
+ }
+
+ static HttpRequest putRequest(prefix, File file, user, password) {
+ def body = HttpRequest.BodyPublishers.ofFile(file.toPath())
+ HttpRequest.newBuilder()
+ .uri(new URI("$prefix/$file.name"))
+ .header('Authorization', 'Basic ' + "$user:$password".getBytes('iso-8859-1').encodeBase64())
+ .header('Content-Type', 'octet-stream')
+ .PUT(body)
+ .build()
+ }
+
+ static boolean awaitPublication(url, user, password, int delay, int numTries) {
+ def found = false
+ def request = headRequest(url, user, password)
+ def client = newClient()
+ def response
+ while (!found && numTries-- > 0) {
+ response = client.send(request, HttpResponse.BodyHandlers.discarding())
+ if (response.statusCode() == 200) found = true
+ else sleep delay
+ }
+ found
+ }
+
static WrappedResponse send(HttpClient client, HttpRequest request) {
new WrappedResponse(client.send(request, HttpResponse.BodyHandlers.ofString()))
}
diff --git a/gradle.properties b/gradle.properties
index 8bb8af5..93a1ab3 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,5 +1 @@
-version.grgit=2.3.0
-version.svntools=2.2.1
version.httpbuilderng=1.0.4
-version.sshplugin=2.7.0
-version.sdkmanplugin=1.1.1
diff --git a/gradle/adhoc.gradle b/gradle/adhoc.gradle
index 8327b6b..8f05fb6 100644
--- a/gradle/adhoc.gradle
+++ b/gradle/adhoc.gradle
@@ -3,20 +3,11 @@
import org.apache.tools.ant.taskdefs.condition.Os
buildscript {
- repositories {
- maven {
- url "https://plugins.gradle.org/m2/"
- }
- }
-
- dependencies {
- classpath "org.ajoberstar:grgit:${getProperty('version.grgit')}"
- classpath "at.bxm.gradleplugins:gradle-svntools-plugin:${getProperty('version.svntools')}"
- classpath "org.hidetake:gradle-ssh-plugin:${getProperty('version.sshplugin')}"
- classpath "gradle.plugin.io.sdkman:gradle-sdkvendor-plugin:${getProperty('version.sdkmanplugin')}"
- }
+ apply from: "gradle/buildscript.gradle", to: buildscript
}
+ext.grgitClass = org.ajoberstar.grgit.Grgit
+
ssh.settings {
dryRun = project.hasProperty('dryRun')
// TODO explore whether this can be made more secure - below not working on windows
@@ -68,7 +59,6 @@
task untagVersion(dependsOn: assumesPropsSet) {
doLast {
def apacheCredentials = new Credentials(apacheUser, apachePassword)
-// def apacheCredentials = new Credentials(username: apacheUser, password: apachePassword)
def grgit = grgitClass.open(dir: stagingDir, creds: apacheCredentials)
def tagName = "GROOVY_$underVersion"
def tag = null
diff --git a/gradle/buildscript.gradle b/gradle/buildscript.gradle
new file mode 100644
index 0000000..47e2611
--- /dev/null
+++ b/gradle/buildscript.gradle
@@ -0,0 +1,10 @@
+repositories {
+ maven {
+ url "https://plugins.gradle.org/m2/"
+ }
+}
+
+dependencies {
+ classpath "org.ajoberstar:grgit:2.3.0"
+ classpath "at.bxm.gradleplugins:gradle-svntools-plugin:3.1"
+}
diff --git a/gradle/phase1.gradle b/gradle/phase1.gradle
index 8629b6a..d7dc5e1 100644
--- a/gradle/phase1.gradle
+++ b/gradle/phase1.gradle
@@ -9,21 +9,11 @@
import org.apache.tools.ant.taskdefs.condition.Os
buildscript {
- repositories {
- maven {
- url "https://plugins.gradle.org/m2/"
- }
- }
-
- dependencies {
- classpath "org.ajoberstar:grgit:${getProperty('version.grgit')}"
- classpath "at.bxm.gradleplugins:gradle-svntools-plugin:${getProperty('version.svntools')}"
- classpath "org.hidetake:gradle-ssh-plugin:${getProperty('version.sshplugin')}"
- classpath "gradle.plugin.io.sdkman:gradle-sdkvendor-plugin:${getProperty('version.sdkmanplugin')}"
- }
+ apply from: "gradle/buildscript.gradle", to: buildscript
}
+apply plugin: at.bxm.gradleplugins.svntools.SvnToolsPlugin
-apply plugin: "at.bxm.svntools"
+ext.grgitClass = org.ajoberstar.grgit.Grgit
svntools {
username = apacheUser
diff --git a/gradle/phase2.gradle b/gradle/phase2.gradle
index ffd7a6d..aa84776 100644
--- a/gradle/phase2.gradle
+++ b/gradle/phase2.gradle
@@ -3,29 +3,16 @@
import at.bxm.gradleplugins.svntools.tasks.SvnCheckout
import at.bxm.gradleplugins.svntools.tasks.SvnCommit
import at.bxm.gradleplugins.svntools.tasks.SvnDelete
-import groovyx.net.http.HttpBuilder
import org.ajoberstar.grgit.Credentials
buildscript {
- repositories {
- jcenter()
- maven {
- url "https://plugins.gradle.org/m2/"
- }
- }
-
+ apply from: "gradle/buildscript.gradle", to: buildscript
dependencies {
- classpath "org.ajoberstar:grgit:${getProperty('version.grgit')}"
- classpath "at.bxm.gradleplugins:gradle-svntools-plugin:${getProperty('version.svntools')}"
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')}"
}
}
-apply plugin: "at.bxm.svntools"
-apply plugin: "org.hidetake.ssh"
-apply plugin: "io.sdkman.vendors"
+ext.grgitClass = org.ajoberstar.grgit.Grgit
svntools {
username = apacheUser
@@ -60,30 +47,25 @@
task jiraCheckPhase2(dependsOn: assumesRelVersion) {
doLast {
- 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 }
+ def prefix = 'https://issues.apache.org/jira/rest/api/2'
+ def client = HttpUtil.newClient()
+ def request = HttpUtil.getRequest("$prefix/project/GROOVY/versions", apacheUser, apachePassword)
+ def response = HttpUtil.send(client, request)
+ assert response.statusCode() == 200
+ def versionFields = response.json.find { it.name == relVersion }
assert versionFields, "Version $relVersion not found in Jira!"
assert versionFields.released, "Version $relVersion not yet released!"
project.ext.versionId = versionFields.id
project.ext.projectId = versionFields.projectId
- resp = jira.get {
- request.uri.path = "$prefix/version/$versionId/unresolvedIssueCount"
- }
- if (resp.issuesUnresolvedCount) {
+ request = HttpUtil.getRequest("$prefix/version/$versionId/unresolvedIssueCount", apacheUser, apachePassword)
+ response = HttpUtil.send(client, request)
+ if (response.json.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
+ request = HttpUtil.getRequest("$prefix/version/$versionId/relatedIssueCounts", apacheUser, apachePassword)
+ response = HttpUtil.send(client, request)
+ project.ext.fixCount = response.json.issuesFixedCount
}
}
@@ -194,17 +176,13 @@
group = "Post-passed phase"
description = "Publish distribution zips to Groovy artifactory instance"
doLast {
- def artifactory = HttpBuilder.configure {
- request.uri = 'https://groovy.jfrog.io/'
- request.headers['Authorization'] = 'Basic ' + "$artifactoryUser:$artifactoryPassword".getBytes('iso-8859-1').encodeBase64()
- }
+ def prefix = 'https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips'
+ def client = HttpUtil.newClient()
fileTree("$distParentDir/distributions").files.each { File f ->
println "Uploading $f.name"
- artifactory.put {
- request.uri.path = "/artifactory/dist-release-local/groovy-zips/${f.name}"
- request.body = f.bytes
- request.contentType = 'application/octet-stream'
- }
+ def request = HttpUtil.putRequest(prefix, f, apacheUser, apachePassword)
+ def response = HttpUtil.send(client, request)
+ assert response.statusCode() == 200
}
println "Zips uploaded! You may need to release manually."
}
@@ -214,22 +192,10 @@
group = "Post-passed phase"
description = "Polls the artifactory instance website to check if it is released"
doLast {
- def found = false
def delay = 30000 // 1/2 a minute
def numTries = 60 // wait for up to 30 mins
- def artifactory = HttpBuilder.configure {
- request.uri = 'https://groovy.jfrog.io/'
- }
- while (!found && numTries-- > 0) {
- found = true
- artifactory.head {
- request.uri.path = "/artifactory/dist-release-local/groovy-zips/apache-groovy-sdk-${relVersion}.zip"
- response.failure { fs ->
- sleep delay
- found = false
- }
- }
- }
+ def url = "https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips/apache-groovy-sdk-${relVersion}.zip"
+ def found = HttpUtil.awaitPublication(url, apacheUser, apachePassword, delay, numTries)
assert found, 'Timed out waiting for artifactory publish/sync - please check manually'
}
}
@@ -396,7 +362,6 @@
group = "Post-passed phase"
description = "Pushes the Groovy website so that the new website is published"
doLast {
-// def githubCredentials = new Credentials(username: githubUser, password: githubPassword)
def githubCredentials = new Credentials(githubUser, githubPassword)
def grgit = grgitClass.open(dir: stagingWebsiteDir, creds: githubCredentials)
grgit.add(patterns: ['sitemap.groovy'])
@@ -411,22 +376,10 @@
group = "Post-passed phase"
description = "Polls the Groovy website to check if the changelog for this version is published"
doLast {
- def found = false
def delay = 30000 // 1/2 a minute
def numTries = 60 // wait for up to 30 mins
- def usersite = HttpBuilder.configure {
- request.uri = 'https://groovy-lang.org'
- }
- while (!found && numTries-- > 0) {
- found = true
- usersite.head {
- request.uri.path = "/changelogs/changelog-${relVersion}.html"
- response.failure { fs ->
- sleep delay
- found = false
- }
- }
- }
+ def url = "https://groovy-lang.org/changelogs/changelog-${relVersion}.html"
+ def found = HttpUtil.awaitPublication(url, apacheUser, apachePassword, delay, numTries)
assert found, 'Timed out waiting for website to be published - please check manually'
}
}
@@ -449,23 +402,19 @@
group = "Post-passed phase"
description = "Make sure that Jira is ready for the next version on this branch"
doLast {
- 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 == nextVersion }
+ def prefix = 'https://issues.apache.org/jira/rest/api/2'
+ def client = HttpUtil.newClient()
+ def request = HttpUtil.getRequest("$prefix/project/GROOVY/versions", apacheUser, apachePassword)
+ def response = HttpUtil.send(client, request)
+ assert response.statusCode() == 200
+ def versionFields = response.json.find { it.name == nextVersion }
if (versionFields) {
println "Version $nextVersion already found in Jira!"
} else {
- jira.post {
- request.uri.path = "$prefix/version"
- request.body = /{ "name": "$nextVersion", "project": "GROOVY", "projectId": $projectId }/
- request.contentType = 'application/json'
- }
+ def body = /{ "name": "$nextVersion", "project": "GROOVY", "projectId": $projectId }/
+ request = HttpUtil.postRequest("$prefix/version", body, apacheUser, apachePassword)
+ response = HttpUtil.send(client, request)
+ assert response.statusCode() == 200
}
}
}