aboutsummaryrefslogtreecommitdiff
path: root/maven-plugin/src
diff options
context:
space:
mode:
authorSergey Mashkov <sergey.mashkov@jetbrains.com>2015-07-10 15:10:36 +0300
committerSergey Mashkov <sergey.mashkov@jetbrains.com>2015-07-13 17:57:44 +0300
commit549ef194efc7a3eee948eac2da4ac36c2e47a6a1 (patch)
treeb712c97ac6de7706adc689f710b85090c6e7ab20 /maven-plugin/src
parent526eb3bce36a582a3b4e9af002273b91ed6b1f63 (diff)
downloaddokka-549ef194efc7a3eee948eac2da4ac36c2e47a6a1.tar.gz
dokka-549ef194efc7a3eee948eac2da4ac36c2e47a6a1.tar.bz2
dokka-549ef194efc7a3eee948eac2da4ac36c2e47a6a1.zip
Maven plugin initial implementation
Diffstat (limited to 'maven-plugin/src')
-rw-r--r--maven-plugin/src/main/kotlin/DokkaMojo.kt71
-rw-r--r--maven-plugin/src/main/kotlin/MavenDokkaLogger.kt18
2 files changed, 89 insertions, 0 deletions
diff --git a/maven-plugin/src/main/kotlin/DokkaMojo.kt b/maven-plugin/src/main/kotlin/DokkaMojo.kt
new file mode 100644
index 00000000..80f00c42
--- /dev/null
+++ b/maven-plugin/src/main/kotlin/DokkaMojo.kt
@@ -0,0 +1,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) {
+ getLog().info("Dokka skip parameter is true so no dokka output will be produced")
+ return
+ }
+
+ val gen = DokkaGenerator(
+ MavenDokkaLogger(getLog()),
+ classpath,
+ sourceDirectories,
+ samplesDirs,
+ includeDirs,
+ moduleName,
+ outputDir,
+ outputFormat,
+ sourceLinks.map { SourceLinkDefinition(it.dir, it.url, it.urlSuffix) }
+ )
+
+ gen.generate()
+ }
+}
diff --git a/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt b/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt
new file mode 100644
index 00000000..ebae823b
--- /dev/null
+++ b/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt
@@ -0,0 +1,18 @@
+package org.jetbrains.dokka.maven
+
+import org.apache.maven.plugin.logging.Log
+import org.jetbrains.dokka.DokkaLogger
+
+public class MavenDokkaLogger(val log: Log) : DokkaLogger {
+ override fun error(message: String) {
+ log.error(message)
+ }
+
+ override fun info(message: String) {
+ log.info(message)
+ }
+
+ override fun warn(message: String) {
+ log.warn(message)
+ }
+} \ No newline at end of file