@@ -29,32 +29,18 @@ import io.spine.gradle.publish.getOrCreate
2929import java.io.File
3030import java.time.LocalDate
3131import org.gradle.api.Project
32+ import org.gradle.api.Task
3233import org.gradle.api.artifacts.Dependency
3334import org.gradle.api.artifacts.dsl.DependencyHandler
34- import org.gradle.api.file.FileCollection
3535import org.gradle.api.tasks.TaskContainer
3636import org.gradle.api.tasks.TaskProvider
3737import org.gradle.api.tasks.bundling.Jar
3838import org.gradle.kotlin.dsl.DependencyHandlerScope
39- import org.jetbrains.dokka.gradle.AbstractDokkaTask
4039import org.jetbrains.dokka.gradle.DokkaExtension
41- import org.jetbrains.dokka.gradle.DokkaTask
42- import org.jetbrains.dokka.gradle.GradleDokkaSourceSetBuilder
4340import org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceSetSpec
4441import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
4542import org.jetbrains.dokka.gradle.engine.plugins.DokkaHtmlPluginParameters
4643
47- /* *
48- * To generate the documentation as seen from Java perspective, the `kotlin-as-java`
49- * plugin was added to the Dokka classpath.
50- *
51- * @see <a href="https://github.com/Kotlin/dokka#output-formats">
52- * Dokka output formats</a>
53- */
54- fun DependencyHandlerScope.useDokkaForKotlinAsJava () {
55- dokkaPlugin(Dokka .KotlinAsJavaPlugin .lib)
56- }
57-
5844/* *
5945 * To exclude pieces of code annotated with `@Internal` from the documentation
6046 * a custom plugin is added to the Dokka classpath.
@@ -72,9 +58,8 @@ private fun DependencyHandler.dokkaPlugin(dependencyNotation: Any): Dependency?
7258/* *
7359 * Resolves the directory where Dokka outputs HTML documentation for the given language.
7460 */
75- internal fun Project.dokkaOutput (language : String ): File {
76- val lng = language.titleCaseFirstChar()
77- return layout.buildDirectory.dir(" docs/dokka$lng " ).get().asFile
61+ internal fun Project.dokkaHtmlOutput (): File {
62+ return layout.buildDirectory.dir(" dokka/html" ).get().asFile
7863}
7964
8065/* *
@@ -187,54 +172,42 @@ private fun DokkaSourceSetSpec.configureSourceSet(config: SourceSetConfig) {
187172}
188173
189174/* *
190- * Configures this [DokkaTask ] to accept only Kotlin files.
175+ * Configures this [DokkaExtension ] to accept only Kotlin files.
191176 */
192177fun DokkaExtension.configureForKotlin (project : Project , sourceLinkRemoteUrl : String ) {
193178 configureFor(project, " kotlin" , sourceLinkRemoteUrl)
194179}
195180
196181/* *
197- * Configures this [DokkaTask ] to accept only Java files.
182+ * Configures this [DokkaExtension ] to accept only Java files.
198183 */
199184@Suppress(" unused" )
200185fun DokkaExtension.configureForJava (project : Project , sourceLinkRemoteUrl : String ) {
201186 configureFor(project, " java" , sourceLinkRemoteUrl)
202187}
203188
204189/* *
205- * Finds the `dokkaHtml ` Gradle task.
190+ * Finds the `dokkaGenerateHtml ` Gradle task.
206191 */
207- fun TaskContainer.dokkaHtmlTask (): DokkaTask ? = this .findByName(" dokkaHtml " ) as DokkaTask ?
192+ fun TaskContainer.dokkaHtmlTask (): Task ? = this .findByName(" dokkaGeneratePublicationHtml " )
208193
209194/* *
210- * Returns only Java source roots out of all present in the source set.
211- *
212- * It is a helper method for generating documentation by Dokka only for Java code.
213- * It is helpful when both Java and Kotlin source files are present in a source set.
214- * Dokka can properly generate documentation for either Kotlin or Java depending on
215- * the configuration, but not both.
195+ * Finds the `dokkaGeneratePublicationJavadoc` Gradle task.
216196 */
217- @Suppress(" unused" )
218- internal fun GradleDokkaSourceSetBuilder.onlyJavaSources (): FileCollection {
219- return sourceRoots.filter(File ::isJavaSourceDirectory)
220- }
221-
222- private fun File.isJavaSourceDirectory (): Boolean {
223- return isDirectory && name == " java"
224- }
197+ fun TaskContainer.dokkaJavadocTask (): Task ? = this .findByName(" dokkaGeneratePublicationJavadoc" )
225198
226199/* *
227- * Locates or creates `dokkaKotlinJar ` task in this [Project].
200+ * Locates or creates `htmlDocsJar ` task in this [Project].
228201 *
229202 * The output of this task is a `jar` archive. The archive contains the Dokka output, generated upon
230203 * Kotlin sources from `main` source set. Requires Dokka to be configured in the target project by
231- * applying `dokka-for-kotlin ` plugin.
204+ * applying `dokka-setup ` plugin.
232205 */
233- fun Project.dokkaKotlinJar (): TaskProvider <Jar > = tasks.getOrCreate(" dokkaKotlinJar " ) {
234- archiveClassifier.set(" dokka " )
235- from(files(dokkaOutput( " kotlin " )))
206+ fun Project.htmlDocsJar (): TaskProvider <Jar > = tasks.getOrCreate(" htmlDocsJar " ) {
207+ archiveClassifier.set(" html-docs " )
208+ from(files(dokkaHtmlOutput( )))
236209
237- tasks.dokkaHtmlTask()?.let { dokkaTask ->
210+ tasks.dokkaHtmlTask()?.let { dokkaTask ->
238211 this @getOrCreate.dependsOn(dokkaTask)
239212 }
240213}
@@ -246,29 +219,13 @@ fun Project.dokkaKotlinJar(): TaskProvider<Jar> = tasks.getOrCreate("dokkaKotlin
246219 * This predicate could be useful for disabling publishing tasks
247220 * when doing, e.g., `publishToMavenLocal` for the purpose of the
248221 * integration tests that (of course) do not test the documentation
249- * generation proces and its resuults .
222+ * generation process and its results .
250223 */
251- fun AbstractDokkaTask .isInPublishingGraph (): Boolean =
224+ fun Task .isInPublishingGraph (): Boolean =
252225 project.gradle.taskGraph.allTasks.any {
253226 it.name == " publish" || it.name.contains(" dokkaGenerate" )
254227 }
255228
256- /* *
257- * Locates or creates `dokkaJavaJar` task in this [Project].
258- *
259- * The output of this task is a `jar` archive. The archive contains the Dokka output, generated upon
260- * Kotlin sources from `main` source set. Requires Dokka to be configured in the target project by
261- * applying `dokka-for-java` and/or `dokka-for-kotlin` script plugin.
262- */
263- fun Project.dokkaJavaJar (): TaskProvider <Jar > = tasks.getOrCreate(" dokkaJavaJar" ) {
264- archiveClassifier.set(" dokka-java" )
265- from(files(dokkaOutput(" java" )))
266-
267- tasks.dokkaHtmlTask()?.let { dokkaTask ->
268- this @getOrCreate.dependsOn(dokkaTask)
269- }
270- }
271-
272229/* *
273230 * Disables Dokka and Javadoc tasks in this `Project`.
274231 *
0 commit comments