Skip to content

Gradle plugin initializes the output directory too eagerly #556

@netvl

Description

@netvl

Describe the bug

Any changes of the Project.outputDir property by another plugin (loaded after the Dokka plugin) or by my own build configuration are not reflected in the default dokka task configuration, resulting in pollution of the project work tree.

Expected behaviour

If I change the output directory for my build, the dokka task should output its results there.

To Reproduce

  1. Add the Dokka build plugin to any Gradle/Kotlin project.
  2. Write something like project.buildDir = "$projectDir/output" after application of the Dokka plugin.
  3. Run ./gradlew dokka and observe that the output is produced not to $projectDir/output but to $projectDir/build, which is the default build directory in Gradle.

Dokka configuration

Dokka configuration does not matter, and this can be reproduced without any configuration.

Installation

  • Operating system: macOS
  • Build tool: Gradle v5.6.4
  • Dokka version: 0.10.0

Additional context

At the moment, the output directory of the dokka task is initialized by directly assigning a String property to a value derived from project.buildDir within the plugin application code. This interacts poorly with build setups where the build directory differs from the default one: if I have a plugin which is applied after Dokka and which modifies the build directory, then the dokka task will still output to the default directory, polluting the project work tree. Same if I modify the build directory in my script - the most important thing is that this modification happens after the Dokka plugin application.

I believe that the proper solution here is to rely on the lazy configuration mechanisms in Gradle, and e.g. change the DokkaTask.outputDirectory type to DirectoryProperty, with the default value derived from project.layout.buildDirectory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions