Grails 3.3.6 not firing DocStart and DocEnd Events for command gradle docs

107 Views Asked by At

I created a new Grails 3.3.6 application.

Following this document to create documentation for my project: Grails Docs

The above document says to use gradle docs or grails doc with following arguments..

Arguments:

--init - Create a template project documentation project (optional)

--pdf - Create PDF output for project documentation (optional)

Fired Events:

DocStart - Before documentation generation begins

DocEnd - After documentation generation completes

I created a scripts folder and added _Events.groovy file with the following contents.

//document-service/scripts/_Events.groovy

eventDocStart = { kind ->
    println "**************************** doc start"
}

eventDocEnd = {
    println "**************************** doc end"
}

When i run gradle docs. Java Docs and groovy docs are running but the events are not getting fired. And --pdf argument does not work.

When i run grails doc. I get Command not found doc

What am I doing wrong?

1

There are 1 best solutions below

0
On BEST ANSWER

The documentation is wrong and this is no longer valid in Grails 3. I overcame my problem by intercepting the gradle docs command.

task generateDocs (type: GenerateDocsTask) {}

tasks.groovydoc.dependsOn(generateDocs)

class GenerateDocsTask extends DefaultTask {

    @TaskAction
    def docGenerate() {
        List urls = project.sourceSets.main.runtimeClasspath.files.collect { it.toURI().toURL() }
        URLClassLoader classLoader = new URLClassLoader(urls as URL[], (ClassLoader) null)
        def gdocGenerator = classLoader.loadClass("com.rax.DocGenerator").newInstance()
        gdocGenerator.generateGdoc(classLoader)
    }
}