Open k-mack opened 4 years ago
That is intended behaviour. You should use the the asciidoctorPdf
task for generating PDFs as it is optimised.
You can have a lot of common behaviour configured via the global asciidoctorj
extension. Failing that you can also use tasks.withType<AbstractAsciidoctorTask>
, but in that case rememeber to add an import to the build file.
@ysb33r thanks for clarifying. I'll continue to use different tasks for the HTML and PDF backends. Perhaps a future version could log a warning/informational message when resources {}
and the pdf
backend is used with the general-purpose asciidoctor
task to encourage this pattern.
(To be fair, the documentation does speak to this: https://github.com/asciidoctor/asciidoctor-gradle-plugin/blame/85878d8/docs/src/docs/asciidoc/parts/asciidoctorj-pdf-plugin.adoc#L28).
When the PDF backend is specified, resources are unnecessarily copied to its output directory. The build script below is enough to reproduce this behavior. As desired, the images directory will be copied to the HTML5 output directory; but it will also be copied to the PDF output directory, which is unnecessary since the images are embedded in the PDF document.
Full reproducer here: https://github.com/k-mack/asciidoctor-gradle-plugin-pdf-images-dir
The workaround is to create separate tasks: one to create the HTML document and one to create the PDF document.