blob: 604279a8c3500a0182e827dbae67bc402f6e18eb [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
ext.modules = [:]
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"])
}
}
task setupModules(dependsOn: assumesPropsSet) {
def type1 = ['.pom', '.pom.asc']
def type1b = ['.pom', '.pom.asc', '-sources.jar', '-sources.jar.asc', '-javadoc.jar', '-javadoc.jar.asc', '-groovydoc.jar', '-groovydoc.jar.asc']
def type2 = ['.jar', '.jar.asc', '.pom', '.pom.asc', '-sources.jar', '-sources.jar.asc', '-indy.jar', '-indy.jar.asc', '-javadoc.jar', '-javadoc.jar.asc', '-groovydoc.jar', '-groovydoc.jar.asc']
def type3 = ['.zip', '.zip.asc', '.pom', '.pom.asc']
def type4 = ['.jar', '.jar.asc', '.pom', '.pom.asc', '-grooid.jar', '-grooid.jar.asc', '-sources.jar', '-sources.jar.asc', '-indy.jar', '-indy.jar.asc', '-javadoc.jar', '-javadoc.jar.asc', '-groovydoc.jar', '-groovydoc.jar.asc']
modules = [
'groovy' : type4, 'groovy-all': type1b,
'groovy-ant' : type2,
'groovy-binary' : type3, 'groovy-bom': type1,
'groovy-cli-commons': type2,
'groovy-cli-picocli': type2, 'groovy-console': type2,
'groovy-datetime' : type2,
'groovy-dateutil' : type2, 'groovy-docgenerator': type2,
'groovy-groovydoc' : type2,
'groovy-groovysh' : type2, 'groovy-jaxb': type2,
'groovy-jmx' : type2,
'groovy-json' : type2,
'groovy-jsr223' : type2, 'groovy-macro': 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-xml' : type2
]
if (relVersion[0] < '3') {
modules << ['groovy-json-direct': type2]
}
if (relVersion[0] < '4') {
modules << ['groovy-bsf': type2]
}
if (relVersion[0] >= '3') {
modules << [
'groovy-astbuilder': type2,
'groovy-yaml': type2
]
}
if (relVersion.startsWith('4')) {
modules += [
'groovy-contracts': type2,
'groovy-ginq': type2,
'groovy-macro-library': type2,
'groovy-toml': type2,
'groovy-typecheckers': type2
]
}
}
task zipFromArtifactory(dependsOn: setupModules) {
doLast {
def groupId = apacheGroupId ? 'org/apache/groovy' : 'org/codehaus/groovy'
def prefix = "https://groovy.jfrog.io/artifactory/libs-release-local/$groupId"
def artifactBase = file("$buildDir/artifacts-$relVersion").absolutePath
def zipDir = file("$buildDir/zips-$relVersion").absolutePath
file(zipDir).mkdirs()
println "Artifact base dir: $artifactBase, zips: $zipDir"
modules.each { m, suffixes ->
def artifactDir = "$artifactBase/$m"
file(artifactDir).mkdirs()
println "Processing ${suffixes.size()} artifacts for $m"
suffixes.each { suffix ->
ant.get(src: "$prefix/$m/$relVersion/$m-$relVersion$suffix", dest: artifactDir)
ant.zip(destfile: "$zipDir/$m-${relVersion}.zip", basedir: artifactDir)
}
}
}
}
// useful when re-populating artifactory/jcentral from a partial build failure
task populateFromCentral(dependsOn: setupModules) {
doLast {
def groupId = apacheGroupId ? 'org/apache/groovy' : 'org/codehaus/groovy'
def prefix = "https://repo1.maven.org/maven2/$groupId"
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"
}
}