forked from springfox/springfox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocumentation.gradle
More file actions
98 lines (79 loc) · 2.7 KB
/
documentation.gradle
File metadata and controls
98 lines (79 loc) · 2.7 KB
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
import springfox.gradlebuild.BuildInfo
import springfox.gradlebuild.utils.ProjectDefinitions
apply plugin: "org.asciidoctor.convert"
apply plugin: 'org.ajoberstar.git-publish'
gitPublish {
// where to publish to (repo must exist)
repoUri = 'https://github.com/springfox/springfox.git'
// branch will be created if it doesn't exist
branch = 'gh-pages'
preserve {
include '**/*'
}
contents {
from "${buildDir}/all-docs"
}
commitMessage = 'Publishing a documentation updates'
}
asciidoctor {
sourceDir = file('docs/asciidoc')
logDocuments = true
separateOutputDirs = false
backends = ['html5']
outputDir = file("${buildDir}/all-docs/docs/snapshot")
attributes 'source-highlighter': 'coderay',
'springfox-current-version': project.version.toString(),
'springfox-released-version': project.rootProject.buildInfo.currentVersion.asText(),
'springfox-swagger-ui-rfc6570-version': "${rootProject.ext.springfoxRfc6570Version}",
toc: 'left',
idprefix: '',
idseparator: '-',
icons: 'font',
encoding: 'utf-8'
}
task allJavadoc(type: Javadoc) {
final def publishables = ProjectDefinitions.publishables(project)
source publishables.collect { it.sourceSets.main.allJava }
classpath = files(publishables.collect { it.sourceSets.main.compileClasspath })
destinationDir = file("${buildDir}/all-docs/javadoc/snapshot")
}
task allDocs {
dependsOn asciidoctor, allJavadoc
doLast {
logger.lifecycle "[RELEASE] Asciidoctor attributes: ${asciidoctor.attributes}"
logger.lifecycle "[RELEASE] Asciidoctor properties: ${asciidoctor.properties}"
}
}
task publishDocs {
dependsOn gitPublishPush
}
task createReleaseDocs(type: Exec, dependsOn: allDocs) {
description = "Creates released version of documentation"
group = "release"
BuildInfo buildInfo = project.rootProject.buildInfo
String symlink = 'current'
String docVersion = buildInfo.currentVersion.asText()
String releaseCommands = ""
["${buildDir}/all-docs/docs/snapshot" : "${buildDir}/all-docs/docs",
"${buildDir}/all-docs/javadoc/snapshot": "${buildDir}/all-docs/javadoc"].each { source, destination ->
String releaseVersionDir = "${destination}/${docVersion}/"
releaseCommands += """
cp -r $source $releaseVersionDir
ln -sf $releaseVersionDir ${destination}/${symlink}
"""
}
def commands = """
$releaseCommands
"""
if (buildInfo.dryRun) {
logger.warn("Will run the following commands:")
logger.warn(commands)
commandLine "sh", "-c", "echo This is a dry run"
return
}
commandLine "sh", "-c", commands
}
task releaseDocs {
dependsOn createReleaseDocs, publishDocs
}
gitPublishPush.dependsOn allDocs