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

How to build files from two different source folders? #192

Closed sboekhoff closed 8 years ago

sboekhoff commented 8 years ago

I'd like to build only

I thought that naming all files explicitly could be the right way:

asciidoctor {
  logDocuments = true
  // html5, docbook45, docbook5, pdf
  backends = ["html5", "docbook45", "docbook5", "pdf"]
  // Also include README.adoc
  sourceDir = file('./')
  sources {
    include 'src/docs/asciidoc/docu-example.adoc', 'README.adoc'
  }
}

Unfortunately, the folder structure is kept for the files built (I'd prefer the have alle built files in build/asciidoc/[pdf, html5,...]).

But even worse: when running Gradle as continuous build (./gradlew -t asciidoctor; http://gradle.org/blog/feature-spotlight-continuous-build/), the build process gets stuck in an infinite loop (probably, because the ./build-folder changes all the time).

Do you know a way out?

aalmiray commented 8 years ago

As a guideline we don't encourage to place sources at the root level, i.e, README.adoc, as the AsccidoctorTask will use all directories specified in sourceDir as inputs, thus addint them to the input cache. this is the reason why your projects build results in and endless loop, as the root dir updatesits cache, which marks it out of date so it does it again, and again.

sboekhoff commented 8 years ago

So, it's not possible to watch single files,...

Now I moved the contents of the README-file to the source folder and included them in ./README.adoc using

include::src/docs/asciidoc/README.adoc[]

Unfortunately GitLab.com does not execute the include, so only the link and not the processed content is shown in the web-interface (Issue 18045).

ysb33r commented 8 years ago

Totaly agree with @aalmiray on not building from the root level. And to answer your question, you can only have one source directory in this version of the plugin. The sources closure is actually a PatternSet which gets applied to the source folder.

In the experimental new model version of the plugin that @pledbrook is working on, it would be possible to have more than one source directory.

mojavelinux commented 8 years ago

Now I moved the contents of the README-file to the source folder and included them in ./README.adoc

Why don't you just have Gradle copy the README.adoc into src/docs/asciidoc, then remove it when the build is done...or just have git ignore it at that location?

mojavelinux commented 8 years ago

Btw, another approach is to use a second task of type AsciidoctorTask that just manages the root README.adoc. Less ideal, but still feasible.