blob: 8f05fb67cafa276444aa78367900333f9cc0c678 [file] [log] [blame]
import org.ajoberstar.grgit.Credentials
import org.ajoberstar.grgit.util.JGitUtil
import org.apache.tools.ant.taskdefs.condition.Os
buildscript {
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
// knownHosts = file(System.getProperty('user.home') + '/.ssh/known_hosts')
knownHosts = allowAnyHosts
}
remotes {
ciServer {
host = 'ci.groovy-lang.org'
user = findProperty('ciserver.user')
password = findProperty('ciserver.password')
//identity = file('id_rsa')
}
}
// use Exec rather than GradleBuild to avoid any issues between gradle versions
task websiteBuild(type: Exec, dependsOn: [assumesRelVersion, checkoutGroovyWebsite]) {
workingDir stagingWebsiteDir
def theArgs = []
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
theArgs += ['cmd', '/C', 'gradlew.bat']
} else {
theArgs += ['sh', './gradlew']
}
theArgs << ':site-dev:webzip'
theArgs << ':site-user:webzip'
commandLine theArgs
}
// NOTE: not normally needed as part of a release since the CI server does
// this automatically upon commit of the changed website
task websitePublishUserSite(dependsOn: websiteBuild) {
description = "Manual upload of documentation to the Groovy website server"
doLast {
println "WARNING: result might be overridden by CI server"
ssh.run {
session(remotes.ciServer) {
execute 'uname -a'
file("$stagingWebsiteDir/site-user/build/site").listFiles().each {
put from: it, into: '/var/www/beta'
}
// execute 'chgrp -R teamcity /var/www/beta'
}
}
}
}
task untagVersion(dependsOn: assumesPropsSet) {
doLast {
def apacheCredentials = new Credentials(apacheUser, apachePassword)
def grgit = grgitClass.open(dir: stagingDir, creds: apacheCredentials)
def tagName = "GROOVY_$underVersion"
def tag = null
try {
tag = JGitUtil.resolveTag(grgit.repository, tagName)
} catch (ignore) {
println "Exception message: " + ignore.message
}
assert tag, "Tag $tagName is supposed to exist but doesn't!"
grgit.tag.remove(names: [tagName])
grgit.push(tags: true)
grgit.push(refsOrSpecs: [":refs/tags/$tagName"])
}
}
// useful when re-populating artifactory/jcentral from a partial build failure
task populateFromCentral(dependsOn: assumesPropsSet) {
doLast {
def type1 = ['.pom', '.pom.asc']
def type2 = ['.jar', '.jar.asc', '.pom', '.pom.asc']
def type3 = ['.zip', '.zip.asc', '.pom', '.pom.asc']
def type4 = ['.jar', '.jar.asc', '.pom', '.pom.asc', '-grooid.jar', '-grooid.jar.asc']
def modules = [
'groovy': type4, 'groovy-all': type1,
'groovy-ant': type2, 'groovy-astbuilder': type2,
'groovy-binary': type3, 'groovy-bom': type1,
'groovy-bsf': type2, 'groovy-cli-commons': type2,
'groovy-cli-picocli': type2, 'groovy-console': type2,
'groovy-contracts': type2, 'groovy-datetime': type2,
'groovy-dateutil': type2, 'groovy-docgenerator': type2,
'groovy-ginq': type2, 'groovy-groovydoc': type2,
'groovy-groovysh': type2, 'groovy-jaxb': type2,
'groovy-jmx': type2, 'groovy-json': type2,
'groovy-jsr223': type2, 'groovy-macro': type2,
'groovy-macro-library': type2, 'groovy-nio': type2,
'groovy-servlet': type2, 'groovy-sql': type2,
'groovy-swing': type2, 'groovy-templates': type2,
'groovy-test': type4, 'groovy-test-junit5': type2,
'groovy-testng': type2, 'groovy-typecheckers': type2,
'groovy-xml': type2, 'groovy-yaml': type2
]
def prefix = 'https://repo1.maven.org/maven2/org/apache/groovy'
modules.each { m, suffixes ->
println "Processing ${suffixes.size()} artifacts for $m"
suffixes.each { suffix ->
def dest = suffix == '.pom' ?
stagingDir + (m == 'groovy' ? '' : "/subprojects/$m") + '/build/publications/maven/pom-default.xml' :
suffix == '.pom.asc' ? stagingDir + (m == 'groovy' ? '' : "/subprojects/$m") + '/build/publications/maven/pom-default.xml.asc' :
stagingDir + (m == 'groovy' ? '' : "/subprojects/$m") + '/build/libs'
ant.get(src: "$prefix/$m/$relVersion/$m-$relVersion$suffix", dest: dest)
}
}
}
}
task unreleaseOnJira(dependsOn: jiraCheckPhase2) {
description = "Unrelease on Jira if the VOTE is cancelled"
doLast {
def client = HttpUtil.newClient()
def request = HttpUtil.putRequest("https://issues.apache.org/jira/rest/api/2/version/$versionId",
/{ "released": false, "releaseDate": null }/, apacheUser, apachePassword)
def response = HttpUtil.send(client, request)
assert response.statusCode() == 200
}
}
task showInfo(dependsOn: assumesPropsSet) {
doLast {
println "branch = $branch"
println "relVersion = $relVersion"
println "stagingDir = $stagingDir"
println "newRelease = $newRelease"
println "releaseBuild = $releaseBuild"
println "stableBuild = $stableBuild"
println "nextVersion = $nextVersion"
println "baseVersion = $baseVersion"
println "underVersion = $underVersion"
println "devWorkspace = $devWorkspace"
println "releaseWorkspace = $releaseWorkspace"
println "stagingWebsiteDir = $stagingWebsiteDir"
println "apacheGroupId = $apacheGroupId"
println "distParentDir = $distParentDir"
}
}