forked from grails/grails-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
129 lines (100 loc) · 4.13 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
apply plugin: "base"
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")
ext.grailsHome = explicitGrailsHome ? file(explicitGrailsHome).absolutePath : "$checkOutDir/grails-src"
configurations {
publish
}
buildscript {
repositories {
mavenLocal()
maven { url = "http://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-docs:3.0.0.RC2"
classpath 'org.codehaus.groovy:groovy-all:2.4.0'
}
}
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 << {
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.txt for more information."
def zipFile = "${checkOutDir}/grails-src.zip"
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-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 { !explicitGrailsHome }
task apiDocs(type: Exec, dependsOn: 'fetchGrailsSource') {
commandLine = ["./gradlew", "groovydoc", '--info', '--stacktrace']
workingDir = "${checkOutDir}/grails-src"
environment "GRADLE_OPTS", "-Xmx2048m -Xms256m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError"
}
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/codehaus/groovy/grails").exists()
}.collect {
new File(it, "src/main/groovy/org/codehaus/groovy/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.
sourceDir = new File(projectDir, "src/en")
propertiesFiles = [ new File(projectDir, "gradle.properties") ]
macros = [ new grails.doc.macros.GspTagSourceMacro(searchDirs) ]
}
task publishPdf(type: grails.doc.gradle.PublishPdf, dependsOn: ['publishGuide'])
tasks.addRule("Pattern: publishGuide_<lang>") { String taskName ->
def m = taskName =~ /publishGuide_(\w+)/
if (m) {
def lang = m[0][1]
task(taskName, type: grails.doc.gradle.PublishGuide, dependsOn: ['apiDocs', 'copyApiDocs']) {
language = lang
}
}
}
tasks.addRule("Pattern: publishPdf_<lang>") { String taskName ->
def m = taskName =~ /publishPdf_(\w+)/
if (m) {
def lang = m[0][1]
task(taskName, type: grails.doc.gradle.PublishPdf, dependsOn: "publishGuide_${lang}") {
language = lang
}
}
}
task docs(dependsOn: ['publishPdf'])
if (System.getProperty("all.langs")) {
for (f in new File(projectDir, "src").listFiles()) {
if (f.directory && !(f.name in ["en", "guide", "ref"])) {
docs.dependsOn << "publishPdf_${f.name}"
}
}
}
task dist(type: Zip, dependsOn: 'docs') {
from outputDir
}
artifacts {
archives dist
}