How to generate Groovydoc of Plugin

I am preparing junit4ks as a Katalon plugin. I wanted to publish the API doc of junit4ks generated by Groovydoc. Here is the link to it on GitHub. I needed to change my junit4ks/build.gradle to generate the groovydoc. Here I would show it.

plugins {
    id 'java'
    id 'groovy'
    id 'com.github.johnrengelman.shadow' version '4.0.4'
    id "com.katalon.gradle-plugin" version "0.0.6"

ext {
    groovyVersion   = '2.4.7'

configurations {

repositories {
dependencies {
    generateDocs "org.codehaus.groovy:groovy-all:${groovyVersion}"
sourceSets {
    main {
        groovy {
            srcDirs = ['Keywords', 'Include/scripts/groovy']
            srcDir 'Libs'

katalon {
    dependencyPrefix = "com.katalon"
    minimize = false

task groovydoc(type: Groovydoc, overwrite:true) {
    source = sourceSets.main.groovy
    classpath = configurations.compile
    groovyClasspath = project.configurations.generateDocs
    include 'com/kazurayam/junit4ks/*'
    exclude '**/*Test.groovy'
task publishGroovydoc(type: Copy) {
    from 'build/docs/groovydoc'
    into 'docs/api'
groovydoc.finalizedBy publishGroovydoc

task groovydoc will generate HTML files into build/docs/groovydoc. However Github Pages required files to be located under the docs directory. Therefore I added task publishGroovydoc and groovydoc.finalizedBy statemenents to copy files from build/docs/groovydoc to docs/api.

task groovydoc required me to declare depencency to the groovy-all.jar. I specified the version 2.4.7 here, but I am not sure if it is appropriate.

I could find this trick (copying the groovydoc files from A to B on the task finalized) because I know Gradle better. I do not know how to implement this trick in Maven. This is why I prefer Gradle to Maven.

I used Github Pages to publish the groovydoc. I am wondering how Katalon Store is going to accomodate the API docs of plugins. Is Katalon Store going to provide “Github Pages” equivalent?


Thank you @kazurayam. Is this the final version? Would you mind if I add its to the plugin docs?

I woud add a line:

defaultTasks groovydoc

I do not think it is a good idea to extend the “build.gradle” file to include codes for groovydoc. That makes the file quite messy. I would rather like to create another file “groovydoc.gradle” which is speciallized for groovy doc, and I would execute:

$ gradle -b groovydoc.gradle
1 Like

Yes that makes sense.

    id 'com.github.johnrengelman.shadow' version '4.0.4'
    id "com.katalon.gradle-plugin" version "0.0.6"

groovydoc.gradle would not require these 2 plugins.

1 Like