On 17/07/2012, at 9:31 PM, Luke Daley wrote:

> Howdy,
> 
> Currently, the @Nested task annotation only considers the declared type and 
> not the real type. Consider…
> 
> interface MarkdownProcessor {
>    void markdown(Reader markdown, Writer html)
> }
> 
> class PegdownMarkdownProcessor implements MarkdownProcessor {
>    @Input int options = 0
> 
>    void markdown(Reader markdown, Writer html) {
>        def processor = new PegDownProcessor(options)
>        html << processor.markdownToHtml(markdown.text)
>    }
> }
> 
> class Markdown extends DefaultTask {
>    @InputFile File markdown
>    @OutputFile File html
>    @Input String encoding
>    @Nested MarkdownProcessor processor = new PegdownMarkdownProcessor()
> 
>    @TaskAction
>    void markdown() {
>        markdown.withReader(encoding) { markdownReader ->
>            html.withWriter(encoding) { htmlWriter ->
>                processor.markdown(markdownReader, htmlWriter)
>            }
>        }
>    }
> 
>    void processor(Action<MarkdownProcessor> config) {
>        config.execute(processor)
>    }
> }
> 
> That's aiming for there being a generic task, with swappable implementations. 
> This doesn't work if the different components can have different properties 
> that impact incremental build. Is this something we want to support?

Yes, I think so.


--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com

Reply via email to