asciidoctor-gradle-plugin
asciidoctor-gradle-plugin copied to clipboard
Question: Dynamic, source-specific attribute value
Hi,
thanks for your great work on integrating AsciiDoctor with Gradle.
I'm fairly new to the Gradle and AsciiDoctor ecosystems, so please excuse me if this is a trivial question.
I have a repository with multiple .adoc
documents which I would like to convert to HTML using Gradle.
I would like to a attributes to the asciidcotor build, that is specific to the input document and computed by a different gradle task that runs before asciidoctor
I based my solution on the examples repository.
asciidoctor {
baseDirFollowsSourceFile()
sourceDir("docs")
outputDir("artifacts")
sources {
include("document1.adoc")
include("document2.adoc")
}
attributes(
"build-gradle": file("build.gradle"),
"data-uri": "",
"my-custom-attribute": "<VALUE>" // I'd like to calculate "<VALUE>" in a gradle task and the value should be specific to either "document1.adoc" or "document2.adoc"
)
}
So I guess my question boils down to two aspects:
- Can the attribute value be made dynamic and use the output of a previous gradle task?
- Can the attribute value be calculated based on the current document being processed?
I'd be greatly appreciate any pointers on how to achieve this.
If you use 4.x (the alpha versions), then you can use a closure or a provider as the value. It will only be evaluated when the task executes.
Thanks, I'll try that!