Search code examples
mavenkotlinnexusmaven-release-pluginkotlin-dokka

How to generate javadoc jar for repository upload with dokka?


I have recently migrated a java component to kotlin. So far when I used the maven release plugin, it automatically generated the javadoc too and it was also uploaded to oss.sonatype.com. Dokka at the other hand does not seem to be integrated with the release plugin out-of-the-box. As a result, after upload to oss.sonatype.com, nexus rejects release with validation error, because the javadoc jar is missing.

nexus validation results

Is there a dokka integration with the maven release plugin?


Solution

  • Found the problem. Dokka does have the required maven goal (dokka:javadocJar) but unlike with maven-javadoc-plugin, it is not bound to the packaging lifecycle. The easy fix is

                    <plugin>
                    <groupId>org.jetbrains.dokka</groupId>
                    <artifactId>dokka-maven-plugin</artifactId>
                    <version>${dokka.version}</version>
                    <executions>
                        <execution>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>dokka</goal>
                                <goal>javadoc</goal>
                                <goal>javadocJar</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <includes>
                            <file>packages.md</file>
                        </includes>
                    </configuration>
                </plugin>