asciidoctor / asciidoctor-gradle-plugin

A Gradle plugin that uses Asciidoctor via JRuby to process AsciiDoc source files within the project.
https://asciidoctor.github.io/asciidoctor-gradle-plugin/
Apache License 2.0
286 stars 122 forks source link

Custom AsciidoctorTask task needs sourceDir #688

Closed chkpnt closed 10 months ago

chkpnt commented 1 year ago

When using

asciidoctor {
    // ...
}

I do not need to specify sourceDir, as the default src/docs/asciidoc is used.

But if I register my own AsciidoctorTask, sourceDir needs to be specified explicitly, otherwise the Gradle task is executed with "NO SOURCES":

tasks.register("Installation", AsciidoctorTask) {
    group "documentation"
    sourceDir "src/docs/asciidoc"
    sources {
        include "Installation.adoc"
    }
    baseDirFollowsSourceDir()
    outputDir "build/docs/asciidoc/Installation"
}

Why is this the case and more important, am I missing other (important) default settings, too, when using a custom AsciidoctorTask?

ysb33r commented 10 months ago

It is because the asciidoctor task is applied by convention. As we do not know the use cases for additional AsciidoctorTask tasks, we cannot set values for those tasks by convention. This is similar to someone creating additional Jar tasks in a buidl.