Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 64 lines (55 sloc) 2.298 kB
522c0d1 @cbeams Add publishSchema task
cbeams authored
1 apply from: "$rootDir/buildSrc/preconditions.gradle"
2
3 checkForProps(taskPath: project.path + ':publishSchema',
4 requiredProps: ['sshHost', 'sshUsername', 'sshPrivateKey', 'remoteDocRoot'])
5
6 configurations { scpAntTask }
7 dependencies { scpAntTask("org.apache.ant:ant-jsch:1.8.1") }
8
9 /**
10 * @author Chris Beams
11 */
12 task publishSchema << {
13 def props = new Properties()
14 def file = new File("${projectDir}/src/main/resources/META-INF/spring.schemas")
15 if (file.exists()) {
16 file.withInputStream {
17 stream -> props.load(stream)
18 }
19 }
20
21 if (!props.size()) {
22 return
23 }
24
25 project.ant {
26 taskdef(name: 'scp',
27 classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
28 classpath: configurations.scpAntTask.asPath)
29 taskdef(name: 'sshexec',
30 classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec',
31 classpath: configurations.scpAntTask.asPath)
32
33 for (def key : props.keySet()) {
34 // process only explicitly-versioned entries in the file
35 // we'll deal with symlinking to the latest released version
36 // later below
37 // e.g.:
38 // spring-integration-2.0.xsd
39 // but not:
40 // spring-integration.xsd
41 if (key =~ /\d\.xsd/) {
42 // key entries are formatted as http://www.springframework.org/schema/...
43 // strip the protocol and domain, leaving just the path from 'schema' on
44 def remotePath = key.substring(key.indexOf('schema/'))
45 sshexec(keyfile: sshPrivateKey,
46 host: sshHost,
47 username: sshUsername,
48 command: "mkdir -p `dirname ${remoteDocRoot}/${remotePath}`")
49 scp(keyfile: sshPrivateKey,
50 file: "src/main/resources/${props.get(key)}",
51 todir: "${sshUsername}@${sshHost}:${remoteDocRoot}/${remotePath}")
52 }
53 }
54 }
55
56 /*
57 def firstKey = props.keySet().iterator().next()
58 def path = firstKey.substring(firstKey.indexOf('schema/'))
59 def symlinkPath = (path =~ /-\d\.\d/).replaceFirst('')
60
61 println "sshexec ln -s wtf ${symlinkPath}"
62 */
63 }
Something went wrong with that request. Please try again.