Maven Constructing Javadoc information cannot find symbol from Kotlin

42 Views Asked by At

I can successfully compile my maven project using both Kotlin and Java. However javadoc is giving an error because it cannot find a symbol (corresponding to a Kotlin interface) being used in other Java class. NOTE that maven is correctly compiling both types and I am only getting the error in javadocs.

Next are the configured plugins:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.0.1</version>
    <configuration>
        <source>8</source>
    </configuration>
    <executions>
        <execution>
            <id>attach-javadocs</id>
            <goals>
                <goal>
                    jar
                </goal>
            </goals>
        </execution>
    </executions>
</plugin>
...
<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>
                <configuration>
                    <sourceDirs>
                        <source>src/main/java</source>
                        <source>src/main/kotlin</source>
                    </sourceDirs>
                </configuration>
            </execution>
            <execution>
                <id>test-compile</id>
                <phase>test-compile</phase>
                <goals>
                    <goal>test-compile</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <jvmTarget>${maven.compiler.target}</jvmTarget>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <executions>
            <!-- Replacing default-compile as it is treated specially by maven -->
            <execution>
                <id>default-compile</id>
                <phase>none</phase>
            </execution>
            <!-- Replacing default-testCompile as it is treated specially by maven -->
            <execution>
                <id>default-testCompile</id>
                <phase>none</phase>
            </execution>
            <execution>
                <id>java-compile</id>
                <phase>compile</phase>
                <goals> <goal>compile</goal> </goals>
            </execution>
            <execution>
                <id>java-test-compile</id>
                <phase>test-compile</phase>
                <goals> <goal>testCompile</goal> </goals>
            </execution>
        </executions>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
</plugins>
...
1

There are 1 best solutions below

0
Miguel Gamboa On

Replacing javadocs plugin by the jetbrains dokka plugin suppresses the error, but it generates docs only for Java classes and is missing the Kotlin classes.

<plugin>
    <groupId>org.jetbrains.dokka</groupId>
    <artifactId>dokka-maven-plugin</artifactId>
    <version>1.9.10</version>
    <executions>
        <execution>
            <phase>prepare-package</phase>
            <goals>
                <goal>dokka</goal>
                <goal>javadoc</goal>
                <goal>javadocJar</goal>
            </goals>
        </execution>
    </executions>
</plugin>