Skip to content

Commit 692cf58

Browse files
committed
Build: Fix the aggregated javadoc docs task
JAVA-2693
1 parent e18b0ab commit 692cf58

File tree

1 file changed

+55
-47
lines changed

1 file changed

+55
-47
lines changed

build.gradle

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -108,49 +108,8 @@ configure(subprojects.findAll { it.name != 'util' }) {
108108
javadoc {
109109
exclude "**/com/mongodb/**/internal/**"
110110
exclude "**/org/bson/**/internal/**"
111-
112111
dependsOn project(':util').compileJava //We need taglets to be compiled
113-
114-
options.author = true
115-
options.version = true
116-
options.links 'http://docs.oracle.com/javase/7/docs/api/'
117-
options.tagletPath single(project(':util').sourceSets.main.output.classesDirs)
118-
options.taglets 'ManualTaglet'
119-
options.taglets 'DochubTaglet'
120-
options.taglets 'ServerReleaseTaglet'
121-
options.encoding = 'UTF-8'
122-
options.charSet 'UTF-8'
123-
options.docEncoding 'UTF-8'
124-
options.header = '''
125-
<script type="text/javascript">
126-
<!-- Set the location hash in the classFrame -->
127-
try {
128-
locationHash = top.location.hash;
129-
if (window.name == "classFrame" && locationHash != "") {
130-
window.location.hash = locationHash;
131-
}
132-
} catch (error) {}
133-
<!-- GA Tracking code -->
134-
if (window.name == "" || window.name == "classFrame") {
135-
var _elqQ = _elqQ || [];
136-
_elqQ.push(["elqSetSiteId", "413370795"]);
137-
_elqQ.push(["elqTrackPageView"]);
138-
(function () {
139-
function async_load() { var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; s.src = "//img03.en25.com/i/elqCfg.min.js"; var x = document.getElementsByTagName("script")[0]; x.parentNode.insertBefore(s, x); }
140-
if (window.addEventListener) window.addEventListener("DOMContentLoaded", async_load, false);
141-
else if (window.attachEvent) window.attachEvent("onload", async_load);
142-
})();
143-
}
144-
</script>
145-
'''
146-
147-
// Add --allow-script-in-comments if available (since 1.8.0_121)
148-
try {
149-
if (Class.forName('com.sun.tools.doclets.formats.html.ConfigurationImpl')
150-
.newInstance().optionLength('--allow-script-in-comments') > 0) {
151-
options.addBooleanOption("-allow-script-in-comments", true)
152-
}
153-
} catch (ignored) {}
112+
options { options -> setJavaDocOptions(options) }
154113
}
155114
}
156115

@@ -303,12 +262,61 @@ configure(subprojects.findAll { it.name != 'util' && it.name != 'mongo-java-driv
303262
}
304263

305264
task docs(type: Javadoc) {
306-
source subprojects.grep({ it.name != 'util' }).collect {project -> project.sourceSets.main.allJava }
307-
// options = subprojects.first().javadoc.options
308-
dependsOn = subprojects.first().javadoc.dependsOn
309-
excludes = subprojects.first().javadoc.excludes
310-
classpath = files(subprojects.collect {project -> project.sourceSets.main.compileClasspath})
311265
destinationDir = new File(projectDir, 'build/docs')
266+
options { options -> setJavaDocOptions(options) }
267+
subprojects.grep({ it.name != 'util' }).each { proj ->
268+
proj.tasks.withType(Javadoc).each { javadocTask ->
269+
source += javadocTask.source
270+
classpath += javadocTask.classpath
271+
excludes += javadocTask.excludes
272+
includes += javadocTask.includes
273+
dependsOn +=javadocTask.dependsOn
274+
}
275+
}
276+
}
277+
278+
def setJavaDocOptions(MinimalJavadocOptions options) {
279+
options.author = true
280+
options.version = true
281+
options.links 'http://docs.oracle.com/javase/7/docs/api/'
282+
options.tagletPath single(project(':util').sourceSets.main.output.classesDirs)
283+
options.taglets 'ManualTaglet'
284+
options.taglets 'DochubTaglet'
285+
options.taglets 'ServerReleaseTaglet'
286+
options.encoding = 'UTF-8'
287+
options.charSet 'UTF-8'
288+
options.docEncoding 'UTF-8'
289+
options.header = '''
290+
<script type="text/javascript">
291+
<!-- Set the location hash in the classFrame -->
292+
try {
293+
locationHash = top.location.hash;
294+
if (window.name == "classFrame" && locationHash != "") {
295+
window.location.hash = locationHash;
296+
}
297+
} catch (error) {}
298+
<!-- GA Tracking code -->
299+
if (window.name == "" || window.name == "classFrame") {
300+
var _elqQ = _elqQ || [];
301+
_elqQ.push(["elqSetSiteId", "413370795"]);
302+
_elqQ.push(["elqTrackPageView"]);
303+
(function () {
304+
function async_load() { var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; s.src = "//img03.en25.com/i/elqCfg.min.js"; var x = document.getElementsByTagName("script")[0]; x.parentNode.insertBefore(s, x); }
305+
if (window.addEventListener) window.addEventListener("DOMContentLoaded", async_load, false);
306+
else if (window.attachEvent) window.attachEvent("onload", async_load);
307+
})();
308+
}
309+
</script>
310+
'''
311+
312+
// Add --allow-script-in-comments if available (since 1.8.0_121)
313+
try {
314+
if (Class.forName('com.sun.tools.doclets.formats.html.ConfigurationImpl')
315+
.newInstance().optionLength('--allow-script-in-comments') > 0) {
316+
options.addBooleanOption("-allow-script-in-comments", true)
317+
}
318+
} catch (ignored) {
319+
}
312320
}
313321

314322
//////////////////////////////////////////

0 commit comments

Comments
 (0)