-
Notifications
You must be signed in to change notification settings - Fork 6
/
javadoc.gradle.kts
57 lines (52 loc) · 2.44 KB
/
javadoc.gradle.kts
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
val mathJax = "<script type='text/x-mathjax-config'>MathJax.Hub.Config({ tex2jax: { inlineMath: [ ['$','$'] ], processEscapes: true } });</script><script type='text/javascript' src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>"
tasks.named<Javadoc>("javadoc") {
options.header("")
.bottom(mathJax)
if (JavaVersion.current().isJava9Compatible()) {
options.header("")
.addBooleanOption("-allow-script-in-comments", true)
} else {
// Add --allow-script-in-comments if available (since 1.8.0_121).
// See https://github.com/gradle/gradle/issues/1393
try {
var clazz = Class.forName("com.sun.tools.doclets.formats.html.ConfigurationImpl")
var optionLength = clazz.getDeclaredMethod("optionLength", String::class.java)
var result = optionLength.invoke(clazz.newInstance(), "--allow-script-in-comments") as Int
if (result > 0) {
options.header("")
.addBooleanOption("-allow-script-in-comments", true)
}
} catch (ignored: ClassNotFoundException) {
} catch (ignored: NoSuchMethodException) {
}
}
}
val docsDir: File by project
tasks.register<Javadoc>("internalDocs") {
source = project.the<SourceSetContainer>()["main"].allJava
destinationDir = file("${docsDir}/internal")
// "options" itself is the MinimalJavadocOptions interface.
// For some reason this is the only way to access the
// StandardJavadocDocletOptions backend.
options.header("")
.addBooleanOption("private", true)
options.header("")
.bottom(mathJax)
if (JavaVersion.current().isJava9Compatible()) {
options.header("")
.addBooleanOption("-allow-script-in-comments", true)
} else {
// Add --allow-script-in-comments if available (since 1.8.0_121).
try {
var clazz = Class.forName("com.sun.tools.doclets.formats.html.ConfigurationImpl")
var optionLength = clazz.getDeclaredMethod("optionLength", String::class.java)
var result = optionLength.invoke(clazz.newInstance(), "--allow-script-in-comments") as Int
if (result > 0) {
options.header("")
.addBooleanOption("-allow-script-in-comments", true)
}
} catch (ignored: ClassNotFoundException) {
} catch (ignored: NoSuchMethodException) {
}
}
}