Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Dynamic, source-specific attribute value #676

Open
ap0llo opened this issue Jun 5, 2023 · 2 comments
Open

Question: Dynamic, source-specific attribute value #676

ap0llo opened this issue Jun 5, 2023 · 2 comments

Comments

@ap0llo
Copy link

ap0llo commented Jun 5, 2023

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.

@ysb33r
Copy link
Member

ysb33r commented Jun 5, 2023

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.

@ap0llo
Copy link
Author

ap0llo commented Jun 6, 2023

Thanks, I'll try that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants