Skip to content

Commit 80f928f

Browse files
ctruedenclaude
andcommitted
Generate javadoc JAR for Kotlin projects via Dokka
The maven-javadoc-plugin cannot document Kotlin sources, so pure-Kotlin projects produced no javadoc JAR ("No Javadoc in project. Archive not created."). This caused releases to Maven Central to be rejected, since Central requires a javadoc JAR for every published artifact. The kotlin profile already ran Dokka's dokka and javadoc goals at pre-site, but those only generate HTML for the project site; they never build or attach a -javadoc.jar to the release. Fix this in the kotlin profile by adding a Dokka javadocJar execution that builds and attaches the javadoc-classified JAR. Dokka documents both Kotlin and Java sources, so it also covers mixed projects. To avoid attaching two conflicting javadoc-classifier JARs in that case, skip the maven-javadoc-plugin for Kotlin projects via the javadoc.skip property, honored in all three javadoc-attaching profiles (deploy-to-scijava, sonatype-oss-release, build-javadoc). So that Dokka runs in exactly the same circumstances the maven-javadoc-plugin would -- only at release, not on every build -- bind its phase to the new scijava.javadoc.kotlin.phase property, which defaults to "none" and is flipped to "package" by those same three profiles. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 78a89a9 commit 80f928f

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

pom.xml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@
219219
<scijava.javadoc.url.java>https://javadoc.scijava.org/Java8/</scijava.javadoc.url.java>
220220
<scijava.javadoc.url.javafx>https://javadoc.scijava.org/JavaFX8/</scijava.javadoc.url.javafx>
221221

222+
<!--
223+
Lifecycle phase at which Kotlin projects build their javadoc JAR via
224+
Dokka (see the kotlin profile). Defaults to "none" so a normal build
225+
does not pay the cost; the javadoc-attaching profiles (deploy-to-scijava,
226+
sonatype-oss-release, build-javadoc) override it to "package", matching
227+
when the maven-javadoc-plugin runs for non-Kotlin projects.
228+
-->
229+
<scijava.javadoc.kotlin.phase>none</scijava.javadoc.kotlin.phase>
230+
222231
<!-- Command to use when invoking java via "mvn -Pexec". -->
223232
<scijava.exec.java>java</scijava.exec.java>
224233

@@ -1196,6 +1205,13 @@
11961205
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
11971206
<kotlin.compiler.jvmTarget>${scijava.jvm.version}</kotlin.compiler.jvmTarget>
11981207
<kotlin-maven-plugin.version>${kotlin.version}</kotlin-maven-plugin.version>
1208+
<!--
1209+
NB: The maven-javadoc-plugin cannot document Kotlin sources, so for
1210+
Kotlin (and mixed Kotlin/Java) projects we skip it and let Dokka's
1211+
javadocJar goal (below) produce the javadoc JAR instead. This is
1212+
honored by the deploy-to-scijava and sonatype-oss-release profiles.
1213+
-->
1214+
<javadoc.skip>true</javadoc.skip>
11991215
</properties>
12001216
<dependencies>
12011217
<dependency>
@@ -1313,13 +1329,36 @@
13131329
<artifactId>dokka-maven-plugin</artifactId>
13141330
<version>${dokka-maven-plugin.version}</version>
13151331
<executions>
1332+
<!-- Generate HTML and Javadoc-style docs for the project site. -->
13161333
<execution>
1334+
<id>generate-site-docs</id>
13171335
<phase>pre-site</phase>
13181336
<goals>
13191337
<goal>dokka</goal>
13201338
<goal>javadoc</goal>
13211339
</goals>
13221340
</execution>
1341+
<!--
1342+
Build and attach the javadoc JAR. Dokka documents both
1343+
Kotlin and Java sources, replacing the maven-javadoc-plugin
1344+
(which cannot read Kotlin) for the release artifact that
1345+
Maven Central requires. The Kotlin source root is registered
1346+
by build-helper at generate-sources, so it is available here.
1347+
1348+
The phase is a property defaulting to "none" (see the main
1349+
properties block), so this does not run on a normal build.
1350+
The same profiles that attach javadocs via the
1351+
maven-javadoc-plugin (deploy-to-scijava, sonatype-oss-release,
1352+
build-javadoc) flip it to "package", so Dokka runs in exactly
1353+
the same circumstances the maven-javadoc-plugin would.
1354+
-->
1355+
<execution>
1356+
<id>attach-javadoc-jar</id>
1357+
<phase>${scijava.javadoc.kotlin.phase}</phase>
1358+
<goals>
1359+
<goal>javadocJar</goal>
1360+
</goals>
1361+
</execution>
13231362
</executions>
13241363
</plugin>
13251364
</plugins>
@@ -1574,6 +1613,10 @@
15741613
<!-- The deploy-to-scijava profile enables deployment to the SciJava Maven repository. -->
15751614
<profile>
15761615
<id>deploy-to-scijava</id>
1616+
<properties>
1617+
<!-- Build the Dokka javadoc JAR here too, for Kotlin projects. -->
1618+
<scijava.javadoc.kotlin.phase>package</scijava.javadoc.kotlin.phase>
1619+
</properties>
15771620
<build>
15781621
<plugins>
15791622
<plugin>
@@ -1610,6 +1653,10 @@
16101653
<!-- The sonatype-oss-release profile enables releasing to the OSS Sonatype repository. -->
16111654
<profile>
16121655
<id>sonatype-oss-release</id>
1656+
<properties>
1657+
<!-- Build the Dokka javadoc JAR here too, for Kotlin projects. -->
1658+
<scijava.javadoc.kotlin.phase>package</scijava.javadoc.kotlin.phase>
1659+
</properties>
16131660
<build>
16141661
<plugins>
16151662
<plugin>
@@ -1635,6 +1682,10 @@
16351682
</plugin>
16361683
<plugin>
16371684
<artifactId>maven-javadoc-plugin</artifactId>
1685+
<configuration>
1686+
<!-- NB: Skipped for Kotlin projects; see the kotlin profile. -->
1687+
<skip>${javadoc.skip}</skip>
1688+
</configuration>
16381689
<executions>
16391690
<execution>
16401691
<id>attach-javadocs</id>
@@ -1899,6 +1950,10 @@
18991950
-->
19001951
<profile>
19011952
<id>build-javadoc</id>
1953+
<properties>
1954+
<!-- For Kotlin projects: build the Dokka javadoc JAR here too. -->
1955+
<scijava.javadoc.kotlin.phase>package</scijava.javadoc.kotlin.phase>
1956+
</properties>
19021957
<build>
19031958
<defaultGoal>package</defaultGoal>
19041959
<plugins>
@@ -1913,6 +1968,9 @@
19131968
</execution>
19141969
</executions>
19151970
<configuration>
1971+
<!-- NB: Skipped for Kotlin projects; see the kotlin profile. -->
1972+
<skip>${javadoc.skip}</skip>
1973+
19161974
<!-- Include direct dependencies -->
19171975
<includeDependencySources>true</includeDependencySources>
19181976

0 commit comments

Comments
 (0)