[New software model] Controlling which binaries apply to a component

I’m currently experimenting with the new software model in the Asciidoctor Gradle plugin. Asciidoctor projects are, in large part, easy to model with the component-binary-sourceset structure. The bit I’m unsure about is the binaries.

Each Asciidoctor project can be processed into different output formats, such as HTML, Docbook and PDF. It seems like these output formats should be modelled as different types of BinarySpec and I can work out how to set up these core binaries via a @ComponentBinaries rule. I’m just having trouble with a couple of aspects:

  1. Can a user specify which binary types to output for a given component in the model DSL? For example, they may just want the HTML output without PDF or Docbook.

  2. Can a user specify a custom (i.e. non-core) binary spec for a component in the model DSL? I’ve seen examples of configuring custom components and source sets, but nothing that shows custom binaries.

I understand that I could generate tasks for all combinations of component and binary, leaving it up to the user to control which tasks they run, but then they have to mess around with task dependencies. Shouldn’t the output formats for a component be part of the model specification?

If you add a binary for a component, it’ll get added to the “MyComponent” and “assemble” lifecycle tasks, so it’d always be built, unless you run only the specific lifecycle task for the binary, e.g. MyComponentPdf, MyComponentHtml, or filter it out in some other way.

Thanks for the response. I think that’s fine for Asciidoctor. What I’m still struggling to see is how one can specify which binary specs to use for a given component. I suspect one can do it at a global level:

model {
    binaries {

but this doesn’t really work because I want each binary spec to have a reference to the component (purely for naming of the relevant tasks). Perhaps the above syntax works nested inside a component definition, but I haven’t seen any examples of that.