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