Refactored ssh uploading into a separate gradle task. Added "uploadFaq" task
This commit is contained in:
parent
ca91b9abc5
commit
a097a47246
73
build.gradle
73
build.gradle
|
@ -41,8 +41,6 @@ dependencies {
|
|||
"net.java.dev.jets3t:jets3t:0.6.1"
|
||||
}
|
||||
|
||||
def docsDir = new File(project(':manual').buildDir, 'docs')
|
||||
|
||||
task apidocs(type: Javadoc) {
|
||||
destinationDir = new File(buildDir, 'apidocs')
|
||||
title = "Spring Security $version API"
|
||||
|
@ -57,34 +55,8 @@ task apidocs(type: Javadoc) {
|
|||
})
|
||||
}
|
||||
|
||||
task apitar(type: Tar, dependsOn: apidocs) {
|
||||
compression = Compression.BZIP2
|
||||
classifier = 'apidocs'
|
||||
into('apidocs') {
|
||||
from apidocs.destinationDir
|
||||
}
|
||||
}
|
||||
|
||||
task doctar(type: Tar, dependsOn: ':manual:doc') {
|
||||
compression = Compression.BZIP2
|
||||
classifier = 'doc'
|
||||
into('reference') {
|
||||
from docsDir
|
||||
}
|
||||
}
|
||||
|
||||
task login {
|
||||
// add dynamic properties to login task
|
||||
username = null
|
||||
password = null
|
||||
doFirst {
|
||||
ant {
|
||||
input("Please enter the ssh username for host '$sshHost'", addproperty: "ssh.username")
|
||||
input("Please enter the ssh password '$sshHost'", addproperty: "ssh.password")
|
||||
}
|
||||
username = ant.properties['ssh.username']
|
||||
password = ant.properties['ssh.password']
|
||||
}
|
||||
task docSiteLogin(type: Login) {
|
||||
host = sshHost
|
||||
}
|
||||
|
||||
// Define remoteSiteDir and sshHost in gradle.properties
|
||||
|
@ -94,19 +66,40 @@ if (hasProperty('remoteSiteDir')) {
|
|||
remoteDocsDir="$remoteSiteDir/docs/3.1.x"
|
||||
}
|
||||
|
||||
task uploadApidocs(dependsOn: login) << {
|
||||
ant {
|
||||
scp(file: apitar.archivePath, todir: "$login.username@$sshHost:$remoteDocsDir", password: login.password)
|
||||
sshexec(host: sshHost, username: login.username, password: login.password, command: "cd $remoteDocsDir && tar -xjf ${apitar.archiveName}")
|
||||
sshexec(host: sshHost, username: login.username, password: login.password, command: "rm $remoteDocsDir/${apitar.archiveName}")
|
||||
task uploadApidocs(type: TarUpload) {
|
||||
dependsOn apidocs
|
||||
classifier = 'apidocs'
|
||||
remoteDir = remoteDocsDir
|
||||
login = docSiteLogin
|
||||
|
||||
into('apidocs') {
|
||||
from apidocs.destinationDir
|
||||
}
|
||||
}
|
||||
|
||||
task uploadManual(dependsOn: login) << {
|
||||
ant {
|
||||
scp(file: doctar.archivePath, todir: "$login.username@$sshHost:$remoteDocsDir", password: login.password)
|
||||
sshexec(host: sshHost, username: login.username, password: login.password, command: "cd $remoteDocsDir && tar -xjf ${doctar.archiveName}")
|
||||
sshexec(host: sshHost, username: login.username, password: login.password, command: "rm $remoteDocsDir/${doctar.archiveName}")
|
||||
def docsDir = new File(project(':manual').buildDir, 'docs')
|
||||
|
||||
task uploadDoc(type: TarUpload) {
|
||||
dependsOn ':manual:doc'
|
||||
classifier = 'doc'
|
||||
remoteDir = remoteDocsDir
|
||||
login = docSiteLogin
|
||||
|
||||
into('reference') {
|
||||
from docsDir
|
||||
}
|
||||
}
|
||||
|
||||
task uploadFaq(type: TarUpload) {
|
||||
dependsOn ':faq:docbookHtmlSingle'
|
||||
classifier = 'faq'
|
||||
remoteDir = project.property('remoteSiteDir')
|
||||
login = docSiteLogin
|
||||
|
||||
def faqDir = new File(project(':faq').buildDir, 'docs')
|
||||
|
||||
into('faq') {
|
||||
from faqDir
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.tasks.*;
|
||||
import org.gradle.api.tasks.bundling.Tar;
|
||||
import org.gradle.api.tasks.bundling.Compression;
|
||||
|
||||
/**
|
||||
* Extends the Tar task, uploading the created archive to a remote directory, unpacking and deleting it.
|
||||
* Requires Ant ssh (jsch) support.
|
||||
*/
|
||||
class TarUpload extends Tar {
|
||||
@Input
|
||||
String remoteDir
|
||||
|
||||
@Input
|
||||
Login login
|
||||
|
||||
TarUpload() {
|
||||
compression = Compression.BZIP2
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void copy() {
|
||||
super.copy();
|
||||
upload();
|
||||
}
|
||||
|
||||
def upload() {
|
||||
String username = login.username
|
||||
String password = login.password
|
||||
String host = login.host
|
||||
project.ant {
|
||||
scp(file: archivePath, todir: "$username@$host:$remoteDir", password: password)
|
||||
sshexec(host: host, username: username, password: password, command: "cd $remoteDir && tar -xjf $archiveName")
|
||||
sshexec(host: host, username: username, password: password, command: "rm $remoteDir/$archiveName")
|
||||
}
|
||||
}
|
||||
|
||||
void setLogin(Login login) {
|
||||
dependsOn(login)
|
||||
this.login = login
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores login information for a remote host.
|
||||
*/
|
||||
class Login extends DefaultTask {
|
||||
@Input
|
||||
String host
|
||||
String username
|
||||
String password
|
||||
|
||||
@TaskAction
|
||||
login() {
|
||||
project.ant {
|
||||
input("Please enter the ssh username for host '$host'", addproperty: "user.$host")
|
||||
input("Please enter the ssh password '$host'", addproperty: "pass.$host")
|
||||
}
|
||||
username = ant.properties["user.$host"]
|
||||
password = ant.properties["pass.$host"]
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ defaultTasks 'docbookHtmlSingle'
|
|||
[docbookHtml, docbookFoPdf, docbookHtmlSingle]*.sourceFileName = 'faq.xml'
|
||||
|
||||
docbookHtmlSingle.stylesheet = new File(projectDir, 'src/xsl/html-single-custom.xsl')
|
||||
docbookHtmlSingle.suffix = ''
|
||||
|
||||
docbookHtmlSingle.doLast {
|
||||
resourcesDir = new File(projectDir, 'src/resources')
|
||||
|
|
Loading…
Reference in New Issue