
== Adding API documentation

The `java-library` plugin has built-in support for Java's API documentation tool via the `javadoc` task.

The code generated by the Build Init plugin already placed a comment on the `${sourceFile.raw}` file.
Replace `/*` in the comment by `/**` so that it becomes `javadoc` markup:

.src/main/${languageLC.raw}/${sourceFile.raw}
[source,java]
----
/**
 * This java source file was generated by the Gradle 'init' task.
 */
 ...
----
Run the `javadoc` task.

[listing.terminal.sample-command]
----
\$ ./gradlew javadoc

BUILD SUCCESSFUL
2 actionable tasks: 1 executed, 1 up-to-date
----

You can view the generated `javadoc` files by opening the HTML file located at `${subprojectName.raw}/build/docs/javadoc/index.html`.

You can also generate a Javadoc JAR for your library:

.build.gradle.kts
[source.multi-language-sample,kotlin]
----
java {
    withJavadocJar()
}
----

.build.gradle
[source.multi-language-sample,groovy]
----
java {
    withJavadocJar()
}
----



The additional JAR will be produced as part of the `assemble` or `build` lifecycle tasks and will be part of the publication.
The resulting file is found in `${subprojectName.raw}/build/libs`, with a name using the conventional classifier `-javadoc`.
