diff options
Diffstat (limited to 'maven-plugin')
-rw-r--r-- | maven-plugin/maven-plugin.iml | 46 | ||||
-rw-r--r-- | maven-plugin/pom.xml | 149 | ||||
-rw-r--r-- | maven-plugin/src/main/kotlin/DokkaMojo.kt | 71 | ||||
-rw-r--r-- | maven-plugin/src/main/kotlin/MavenDokkaLogger.kt | 18 |
4 files changed, 284 insertions, 0 deletions
diff --git a/maven-plugin/maven-plugin.iml b/maven-plugin/maven-plugin.iml new file mode 100644 index 00000000..b965c125 --- /dev/null +++ b/maven-plugin/maven-plugin.iml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false"> + <output url="file://$MODULE_DIR$/target/classes" /> + <output-test url="file://$MODULE_DIR$/target/test-classes" /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/plugin" isTestSource="false" generated="true" /> + <excludeFolder url="file://$MODULE_DIR$/target/archive-tmp" /> + <excludeFolder url="file://$MODULE_DIR$/target/classes" /> + <excludeFolder url="file://$MODULE_DIR$/target/lib" /> + <excludeFolder url="file://$MODULE_DIR$/target/maven-archiver" /> + <excludeFolder url="file://$MODULE_DIR$/target/maven-status" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" name="Maven: org.apache.maven:maven-core:3.0.5" level="project" /> + <orderEntry type="library" name="Maven: org.apache.maven:maven-settings:3.0.5" level="project" /> + <orderEntry type="library" name="Maven: org.apache.maven:maven-settings-builder:3.0.5" level="project" /> + <orderEntry type="library" name="Maven: org.apache.maven:maven-repository-metadata:3.0.5" level="project" /> + <orderEntry type="library" name="Maven: org.apache.maven:maven-artifact:3.0.5" level="project" /> + <orderEntry type="library" name="Maven: org.apache.maven:maven-model-builder:3.0.5" level="project" /> + <orderEntry type="library" name="Maven: org.apache.maven:maven-aether-provider:3.0.5" level="project" /> + <orderEntry type="library" name="Maven: org.sonatype.aether:aether-spi:1.13.1" level="project" /> + <orderEntry type="library" name="Maven: org.sonatype.aether:aether-impl:1.13.1" level="project" /> + <orderEntry type="library" name="Maven: org.sonatype.aether:aether-api:1.13.1" level="project" /> + <orderEntry type="library" name="Maven: org.sonatype.aether:aether-util:1.13.1" level="project" /> + <orderEntry type="library" name="Maven: org.sonatype.sisu:sisu-inject-plexus:2.3.0" level="project" /> + <orderEntry type="library" name="Maven: org.sonatype.sisu:sisu-inject-bean:2.3.0" level="project" /> + <orderEntry type="library" name="Maven: org.sonatype.sisu:sisu-guice:no_aop:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: org.sonatype.sisu:sisu-guava:0.9.9" level="project" /> + <orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-interpolation:1.14" level="project" /> + <orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-classworlds:2.4" level="project" /> + <orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-component-annotations:1.5.5" level="project" /> + <orderEntry type="library" name="Maven: org.sonatype.plexus:plexus-sec-dispatcher:1.3" level="project" /> + <orderEntry type="library" name="Maven: org.sonatype.plexus:plexus-cipher:1.4" level="project" /> + <orderEntry type="library" name="Maven: org.apache.maven:maven-model:3.0.5" level="project" /> + <orderEntry type="library" name="Maven: org.apache.maven:maven-plugin-api:3.0.5" level="project" /> + <orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-utils:3.0.22" level="project" /> + <orderEntry type="library" name="Maven: org.apache.maven.plugin-tools:maven-plugin-annotations:3.4" level="project" /> + <orderEntry type="library" name="Maven: org.jetbrains.dokka:dokka-fatjar:1.0" level="project" /> + </component> +</module>
\ No newline at end of file diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml new file mode 100644 index 00000000..de7a5595 --- /dev/null +++ b/maven-plugin/pom.xml @@ -0,0 +1,149 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.jetbrains.dokka</groupId> + <artifactId>dokka-maven-plugin</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>maven-plugin</packaging> + + <properties> + <maven-plugin-anno.version>1.4.1</maven-plugin-anno.version> + <maven.version>3.0.5</maven.version> + <plexus.version>3.0.22</plexus.version> + <kotlin.version>0.1-SNAPSHOT</kotlin.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <version>${maven.version}</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-model</artifactId> + <version>${maven.version}</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>${maven.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + <version>${plexus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-annotations</artifactId> + <version>3.4</version> + </dependency> + + <dependency> + <groupId>org.jetbrains.dokka</groupId> + <artifactId>dokka-fatjar</artifactId> + <version>1.0</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + </dependencies> + + <repositories> + <repository> + <id>my-local-repo</id> + <url>file://${basedir}/../out/repo</url> + </repository> + </repositories> + + <build> + <sourceDirectory>src/main/kotlin</sourceDirectory> + + <plugins> + <plugin> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-maven-plugin</artifactId> + <version>${kotlin.version}</version> + <executions> + <execution> + <id>compile</id> + <phase>compile</phase> + <goals> + <goal>compile</goal> + </goals> + </execution> + <execution> + <id>test-compile</id> + <phase>test-compile</phase> + <goals> + <goal>test-compile</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>3.4</version> + + <executions> + <execution> + <id>default-descriptor</id> + <goals> + <goal>descriptor</goal> + </goals> + <phase>process-classes</phase> + </execution> + <execution> + <id>help-descriptor</id> + <goals> + <goal>helpmojo</goal> + </goals> + <phase>process-classes</phase> + </execution> + </executions> + + <configuration> + <goalPrefix>dokka</goalPrefix> + </configuration> + </plugin> + + <!-- disable default jar building: we use assembly-plugin instead --> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>2.6</version> + <executions> + <execution> + <id>default-jar</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.5.5</version> + <configuration> + <descriptorRefs> + <descriptorRef>jar-with-dependencies</descriptorRef> + </descriptorRefs> + <appendAssemblyId>false</appendAssemblyId> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + + </plugins> + </build> +</project>
\ No newline at end of file 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 |