This repository has been archived by the owner on Mar 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle
162 lines (135 loc) · 5.64 KB
/
build.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'base'
description = "Spring Social Documentation"
task build(dependsOn: assemble) {
group = 'Build'
description = 'Builds reference and API documentation and archives'
}
/**
* Build aggregated JavaDoc HTML for all core project classes. Result is
* suitable for packaging into a distribution zip or viewing directly with
* a browser.
*
* @author cbeams
* @author ltaylor
* @see http://gradle.org/0.9-rc-1/docs/javadoc/org/gradle/api/tasks/javadoc/Javadoc.html
*/
task api(type: Javadoc) {
group = 'Documentation'
description = "Builds aggregated JavaDoc HTML for all core project classes."
// this task is a bit ugly to configure. it was a user contribution, and
// Hans tells me it's on the roadmap to redesign it.
srcDir = file("${projectDir}/src/api")
destinationDir = file("${buildDir}/api")
tmpDir = file("${buildDir}/api-work")
optionsFile = file("${tmpDir}/apidocs/javadoc.options")
options.stylesheetFile = file("${srcDir}/spring-javadoc.css")
options.links = ["http://static.springframework.org/spring/docs/3.0.x/javadoc-api"]
options.overview = "${srcDir}/overview.html"
options.docFilesSubDirs = true
title = "Spring Social ${version} API"
// collect all the sources that will be included in the javadoc output
source javaprojects.collect {project ->
project.sourceSets.main.allJava
}
// collect all main classpaths to be able to resolve @see refs, etc.
// this collection also determines the set of projects that this
// task dependsOn, thus the runtimeClasspath is used to ensure all
// projects are included, not just *dependencies* of all classes.
// this is awkward and took me a while to figure out.
classpath = files(javaprojects.collect {project ->
project.sourceSets.main.runtimeClasspath
})
// copy the images from the doc-files dir over to the target
doLast { task ->
copy {
from file("${task.srcDir}/doc-files")
into file("${task.destinationDir}/doc-files")
}
}
}
/**
*
* @see http://www.gradle.org/0.9-preview-3/docs/userguide/userguide_single.html#sec:copying_files
* @see http://www.gradle.org/0.9-preview-3/docs/javadoc/org/gradle/api/file/CopySpec.html
*/
docsSpec = copySpec {
into("${version}") {
from('src/info/changelog.txt')
}
into("${version}/api") {
from(api.destinationDir)
}
}
task archive(type: Zip, dependsOn: [api]) {
group = "Documentation"
description = "Create a zip archive of reference and API documentation."
baseName = rootProject.name + '-docs'
// drop it right in the root of the build dir for simplicity
destinationDir = buildDir
// use the copy spec above to specify the contents of the zip
with docsSpec
}
configurations { archives }
artifacts { archives archive }
configurations { scpAntTask }
dependencies {
scpAntTask("org.apache.ant:ant-jsch:1.8.1")
}
checkForProps(taskPath: project.path + ':uploadArchives', requiredProps: ['sshHost', 'sshUsername', 'sshPrivateKey'])
uploadArchives {
def sshHost = project.properties.sshHost
def sshUsername = project.properties.sshUsername
def remoteSiteDir = '/var/www/domains/springframework.org/static/htdocs/' + rootProject.name
def docUrl = "http://${sshHost}/${rootProject.name}/docs/${version}"
def remoteDocsDir = "${remoteSiteDir}/docs/"
def fqRemoteDir = "${sshUsername}@${sshHost}:${remoteDocsDir}"
group = 'Buildmaster'
description = "Uploads and unpacks documentation archive" + (sshHost ? " to ${docUrl}" : ": Host is not specified")
uploadDescriptor = false
repositories {
add(new org.apache.ivy.plugins.resolver.SshResolver()) {
name = 'sshHost: ' + sshHost // used for debugging
host = sshHost
user = sshUsername
if (project.hasProperty('sshPrivateKey')) {
keyFile = sshPrivateKey ? sshPrivateKey as File : null
}
addArtifactPattern "${remoteDocsDir}/${archive.archiveName}"
}
}
configurations { scpAntTask }
dependencies { scpAntTask 'org.apache.ant:ant-jsch:1.8.1' }
doFirst {
println "Uploading: ${archive.archivePath} to ${fqRemoteDir}"
}
doLast {
project.ant {
taskdef(name: 'sshexec',
classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec',
classpath: configurations.scpAntTask.asPath)
// copy the archive, unpack it, then delete it
def unpackCommand = "cd ${remoteDocsDir} && unzip -K -o ${archive.archiveName}"
def deleteCommand = "rm ${remoteDocsDir}/${archive.archiveName}"
println "sshexec ${unpackCommand}"
sshexec(host: sshHost, username: sshUsername, keyfile: sshPrivateKey, command: unpackCommand)
println "sshexec ${deleteCommand}"
sshexec(host: sshHost, username: sshUsername, keyfile: sshPrivateKey, command: deleteCommand)
println "UPLOAD SUCCESSFUL - validate by visiting ${docUrl}"
}
}
}