How to make the doxygen plugin fail on undocumented things?

Hi there…

I use the doxygen plugin.
Everything is fine so far, but it does not fail if something is undocumented.

If it was a simple Exec task, it would be easy to capture the output and check it.
The plugin extends from SourceTask, however.

What did I miss?

Well, again I found a possible solution…

This one is written for a task class that simply prints a message.
It’s just a bit of hacking on Sunday evening…

ext.stdOutListener = new TaskStdOutCollector()

class TaskStdOutCollector implements StandardOutputListener {

    String collected = ''

    @Override
    void onOutput(CharSequence charSequence) {
        collected += charSequence.toString()
    }
}

task stdOutAsError(type: MessagePrinter) {
    message = "This should not happen..."
}

gradle.addListener(new TaskExecutionListener() {
    void beforeExecute(Task task) {
        if (task.name =~ /stdOutAsError/) {
            gradle.addListener(project.stdOutListener)
        }
    }

    void afterExecute(Task task, TaskState state) {
        println "afterExecute of $task"
        switch (task.name) {
        case 'stdOutAsError':
            if (project.stdOutListener.collected) {
                throw new GradleException("Did not expect any output from '${task.name}'")
            }
            gradle.removeListener(project.stdOutListener)
            break
        }
    }
})

Which nicely prints on cmd line

  :stdOutAsError
    -------------------------------- stdOutAsError ---------------------------------
    This should not happen...
    afterExecute of task ':stdOutAsError'

    FAILURE: Build failed with an exception.

    * Where:
    Build file '...\build.gradle' line: 69

    * What went wrong:
    Did not expect any output from 'stdOutAsError'