forked from grails/grails-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
119 lines (89 loc) · 3.75 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
import org.apache.tools.ant.taskdefs.condition.Os
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") ?: (project.hasProperty('grails.home') ? project.getProperty("grails.home") : null)
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"
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.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"
}
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.
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'])
task docs(dependsOn: ['publishPdf'])
task dist(type: Zip, dependsOn: 'docs') {
from outputDir
}
artifacts {
archives dist
}