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
|
package org.jetbrains.dokka.maven
import org.apache.maven.plugin.AbstractMojo
import org.apache.maven.plugins.annotations.LifecyclePhase
import org.apache.maven.plugins.annotations.Mojo
import org.apache.maven.plugins.annotations.Parameter
import org.apache.maven.plugins.annotations.ResolutionScope
import org.jetbrains.dokka.DokkaGenerator
import org.jetbrains.dokka.SourceLinkDefinition
public class SourceLinkMapItem {
@Parameter(name = "dir", required = true)
var dir: String = ""
@Parameter(name = "url", required = true)
var url: String = ""
@Parameter(name = "urlSuffix")
var urlSuffix: String? = null
}
@Mojo(name = "dokka", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true)
public class DokkaMojo : AbstractMojo() {
@Parameter(required = true, defaultValue = "\${project.compileSourceRoots}")
var sourceDirectories: List<String> = emptyList()
@Parameter
var samplesDirs: List<String> = emptyList()
@Parameter
var includeDirs: List<String> = emptyList()
@Parameter(required = true, defaultValue = "\${project.compileClasspathElements}")
var classpath: List<String> = emptyList()
@Parameter(required = true, defaultValue = "\${project.basedir}/target/dokka")
var outputDir: String = ""
@Parameter(required = true, defaultValue = "html")
var outputFormat: String = "html"
@Parameter
var sourceLinks: Array<SourceLinkMapItem> = emptyArray()
@Parameter(required = true, defaultValue = "\${project.artifactId}")
var moduleName: String = ""
@Parameter(required = false, defaultValue = "false")
var skip: Boolean = false
override fun execute() {
if (skip) {
log.info("Dokka skip parameter is true so no dokka output will be produced")
return
}
val gen = DokkaGenerator(
MavenDokkaLogger(log),
classpath,
sourceDirectories,
samplesDirs,
includeDirs,
moduleName,
outputDir,
outputFormat,
sourceLinks.map { SourceLinkDefinition(it.dir, it.url, it.urlSuffix) }
)
gen.generate()
}
}
|