forked from grails/grails-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
183 lines (145 loc) · 6.38 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
buildscript {
repositories {
mavenLocal()
maven { url = "http://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-docs:${project.ext.properties.grailsDocsVersion ?: project.'grails.version'}"
classpath 'org.codehaus.groovy:groovy-all:2.4.0'
classpath "org.grails:gdoc-to-asciidoc:1.0.1"
}
}
plugins {
id 'org.asciidoctor.convert' version '1.5.3'
}
asciidoctorj {
version = '1.5.4'
}
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: "base"
apply plugin: "org.grails.grails-gdoc-to-asciidoc"
version = project.getProperty("grails.version")
archivesBaseName = "grails-docs"
ext.checkOutDir = "${buildDir.path}/checkout"
ext.outputDir = "${buildDir.path}/docs"
ext.githubBranch = "master"
ext.explicitGrailsHome = System.getProperty("grails.home") ?: (project.hasProperty('grails.home') ? project.getProperty("grails.home") : null)
ext.grailsHome = explicitGrailsHome ? file(explicitGrailsHome).absolutePath : "$checkOutDir/grails-src"
configurations {
publish
}
gdoc2asciidoc {
apiLinks = ['org.hibernate':'http://docs.jboss.org/hibernate/orm/current/javadocs/',
'org.springframework.boot':'http://docs.spring.io/spring-boot/docs/current/api',
'org.springframework':'http://docs.spring.io/spring/docs/current/javadoc-api/',
'javax.servlet':'http://docs.oracle.com/javaee/1.4/api/',
'java.':'http://docs.oracle.com/javase/6/docs/api/',
'groovy.':'http://docs.groovy-lang.org/docs/latest/html/api/',
'org.codehaus.groovy.grails':"http://docs.grails.org/$githubBranch/api",
'grails.orm.':'http://gorm.grails.org/latest/api',
'grails.gorm.':'http://gorm.grails.org/latest/api',
'grails.':"http://docs.grails.org/$githubBranch/api",
'org.grails.':"http://docs.grails.org/$githubBranch/api"
]
resourcesDir = file("resources")
srcDir = file("src/en")
}
task buildscriptDependencies(type: DependencyReportTask) {
configurations = [buildscript.configurations.classpath]
}
// use jsoup in PdfBuilder for cleaning input html
System.setProperty('grails.docs.clean.html','true')
// creates single.html.before.xml and single.html.after.xml files for debugging pdf input when enabled
//System.setProperty('grails.docs.debug.pdf','true')
task fetchGrailsSource {
doLast {
ant.mkdir dir: checkOutDir
println "Downloading Grails source code. If you already have a copy " +
"of the Grails source code checked out you can avoid this download " +
"by setting the grails.home system property to point to your local " +
"copy of the source. See README.md for more information."
def zipFile = "${checkOutDir}/grails-src.zip"
def tag = System.getenv('TRAVIS_TAG')
if(tag) {
ant.get src: "https://github.com/grails/grails-core/archive/${tag}.zip", dest: zipFile, verbose: true
}
else {
ant.get src: "http://github.com/grails/grails-core/zipball/${githubBranch}", dest: zipFile, verbose: true
}
ant.unzip src: zipFile, dest: checkOutDir, {
mapper type: "regexp", from: "(grails-core-\\S*?/)(.*)", to: "grails-src/\\2"
}
ant.chmod(file:"${checkOutDir}/grails-src/gradlew", perm:700)
println "Grails source code has been downloaded to ${relativePath(grailsHome)}"
}
}
fetchGrailsSource.onlyIf {
println "GRAILS HOME=$explicitGrailsHome"
return !explicitGrailsHome
}
task apiDocs(type: Exec, dependsOn: 'fetchGrailsSource') {
String command = "./gradlew"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
command = "gradlew.bat"
}
commandLine = [command, "groovydoc", '--info', '--stacktrace']
workingDir = grailsHome
environment "GRADLE_OPTS", "-Xmx2048m -Xms256m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError"
}
asciidoctor {
resources {
from('resources')
}
options template_dirs: ["${projectDir}/src/docs/templates"]
attributes 'experimental' : 'true',
'compat-mode' : 'true',
'icons' : 'font',
'linkcss' : 'true',
'docinfo1' : '',
'toc' : 'left',
// stylesdir: "${projectDir}/resources/css",
// stylesheet: 'style.css',
'version' : project.version,
'sourcedir' : "$checkOutDir/grails-src"
}
asciidoctor.dependsOn(apiDocs)
apiDocs.onlyIf { !System.getProperty("disable.groovydocs") }
task copyApiDocs(type: Copy) {
from "${project.grailsHome}/doc/api"
into "${outputDir}/api"
}
task migrate(type: grails.doc.gradle.MigrateLegacyDocs)
task publishGuide(type: grails.doc.gradle.PublishGuide, dependsOn: ['apiDocs', 'copyApiDocs']) {
def searchDirs = project.file(project.grailsHome).listFiles().findAll {
new File(it, "src/main/groovy/org/grails").exists()
}.collect {
new File(it, "src/main/groovy/org/grails")
}
// No language setting because we want the English guide to be
// generated with a 'en' in the path, but the source is in 'en'
// so that it's easy to track with git.
sourceRepo = "https://github.com/grails/grails-doc/edit/$githubBranch/src/en"
sourceDir = new File(projectDir, "src/en")
propertiesFiles = [ new File(projectDir, "gradle.properties") ]
asciidoc = true
properties = [
'javaee': 'https://docs.oracle.com/javaee/7/api/',
'javase': 'https://docs.oracle.com/javase/7/docs/api/',
'groovyapi': 'http://docs.groovy-lang.org/latest/html/gapi/',
'springapi': 'https://docs.spring.io/spring/docs/current/javadoc-api/',
'asyncdocs': 'http://async.grails.org/latest',
'asyncApiDocs': 'http://async.grails.org/latest/api/',
'gspdocs': 'http://gsp.grails.org/latest',
'gspApiDocs': 'http://gsp.grails.org/latest/api/',
'gormApiDocs': 'http://gorm.grails.org/latest/api/',
]
macros = [ new grails.doc.macros.GspTagSourceMacro(searchDirs) ]
}
task publishPdf(type: grails.doc.gradle.PublishPdf, dependsOn: ['publishGuide'])
task docs(dependsOn: ['publishPdf'])
task dist(type: Zip, dependsOn: 'docs') {
from outputDir
}
artifacts {
archives dist
}