-
-
Notifications
You must be signed in to change notification settings - Fork 953
/
Copy pathdocs.gradle
154 lines (136 loc) · 5.62 KB
/
docs.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
import org.grails.gradle.FetchGrailsDocSourceTask
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://repo.grails.org/grails/core" }
}
}
/**
* Since Grails is a mixed Groovy/Java codebase the javadoc tool needs stubs in order for javadoc compilation to pass
* This target generates a set of stubs for the Groovy sources
*/
configurations {
documentation
}
dependencies {
if (compiledByGradleGroovyVersion(project)) {
documentation "org.codehaus.groovy:groovy-groovydoc:$GroovySystem.version"
} else {
documentation "org.apache.groovy:groovy-groovydoc"
}
}
ext.grailsDocSrc = project.findProperty('grails-doc.home') ?: project.buildDir.absolutePath + "/checkout/grails-docs-src"
tasks.register("stubs") {
ext.destinationDir = "$buildDir/docs/stubs"
doFirst {
def isolatedAnt = services.get(org.gradle.api.internal.project.IsolatedAntBuilder)
isolatedAnt.execute {
mkdir(dir: destinationDir)
taskdef(name: "generatestubs", classname: "org.codehaus.groovy.grails.cli.GenerateStubsTask") {
classpath {
for(sub in subprojects) {
pathelement path: sub.sourceSets.main.compileClasspath.asPath
}
}
}
generatestubs(destdir: destinationDir) {
classpath {
for(sub in subprojects) {
pathelement path: sub.sourceSets.main.compileClasspath.asPath
}
}
src {
for (sub in subprojects) {
sub.sourceSets.main.groovy.srcDirs.each { srcDir ->
if (srcDir.exists()) {
dirset(dir: srcDir) {
exclude name: "**/*.properties"
}
}
}
}
}
}
}
}
}
tasks.register('docs') {
group = 'documentation'
outputs.dir(project.layout.buildDirectory.dir('docs').get())
}
task javadoc(type:Javadoc, group: 'documentation') {
def subs = subprojects.findAll { it.name != 'grails-dependencies' && it.name != 'grails-bom' && !it.name.startsWith('grails-test-suite') && !it.name.contains('grails-test-examples') }
classpath = files(subs.configurations.compileClasspath)
dependsOn stubs
maxMemory = '256M'
destinationDir = project.tasks.findByName('docs/javadoc')
source subs.sourceSets.main.groovy.srcDirs + stubs.destinationDir
include "org/codehaus/groovy/grails/**", "grails/**"
exclude "**/**.groovy"
project.configure(options) {
windowTitle = "Grails $grailsVersion"
docTitle = "<h1>Grails</h1>"
encoding = "UTF-8"
memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PACKAGE
author = true
version = true
use = true
breakIterator = true
links("https://java.sun.com/j2ee/1.4/docs/api", "https://java.sun.com/j2se/1.5.0/docs/api", "https://static.springframework.org/spring/docs/2.5.x/api")
// tags("todo:a:To do") todo fix the javadoc task to accept this option
}
verbose = false
}
tasks.register('groovydoc', Groovydoc) {
final Set<Project> subProjects = subprojects.findAll {
!(it.name in ['grails-dependencies', 'grails-bom', 'grails-bootstrap', 'grails-gradle-model', 'grails-shell'])
&& !it.name.startsWith('grails-test-suite') && !it.name.contains('grails-test-examples') }
def groovydocClasspath = files(configurations.documentation + subProjects.configurations.compileClasspath)
// exclude problematic jar file from javadoc classpath
// http://www.adam-bien.com/roller/abien/entry/trouble_with_crippled_java_ee
groovydocClasspath -= groovydocClasspath.filter { it.name == 'javaee-web-api-6.0.jar' }
classpath = groovydocClasspath
groovyClasspath = groovydocClasspath
destinationDir = project.layout.buildDirectory.dir('docs/api').get().asFile
windowTitle = "Grails $grailsVersion"
docTitle = "Grails $grailsVersion"
access = GroovydocAccess.PRIVATE
includeAuthor = true
includeMainForScripts = false
processScripts = false
source subProjects.sourceSets.main.groovy.srcDirs
// Can't make these link methods to work
// link("http://static.springsource.org/spring/docs/3.0.x/javadoc-api", "org.springframework.")
doLast {
delete("${buildDir}/tmp")
}
}
tasks.register("fetchGrailsDocsSource", FetchGrailsDocSourceTask) {
checkoutDir = project.layout.buildDirectory.dir("checkout").get()
grailsDocBranch = "7.0.x"
}
task gdoc(type: GradleBuild, dependsOn: ["groovydoc", "fetchGrailsDocsSource"], group: 'documentation') {
startParameter.useEmptySettings()
dir = grailsDocSrc
tasks = []
doFirst {
ext.oldGrailsHome = System.getProperty("grails.home")
System.setProperty("grails.home", projectDir.absolutePath)
System.setProperty("disable.groovydocs", "true")
}
doLast {
if (ext.oldGrailsHome) System.setProperty("grails.home", (String) project.oldGrailsHome)
else System.clearProperty("grails.home")
System.clearProperty("disable.groovydocs")
ant.mkdir dir: "${projectDir}/dist"
copy {
from "${grailsDocSrc}/build/distributions"
into "${projectDir}/dist"
}
copy {
from layout.buildDirectory.dir("grails-docs-src/build/docs").get()
into layout.buildDirectory.dir("docs/api").get()
}
}
}
docs.dependsOn gdoc