view src/main/groovy/org/ssdt_ohio/gradle/plugins/UserDocPlugin.groovy @ 16:8400a7db1330

USASR-1307: update templates to groovydoc 2.3.6
author smith@nwoca.org
date Wed, 31 Dec 2014 22:35:45 +0000
parents e3c55e83c9a4
children 927f02ccc596
line wrap: on
line source
package org.ssdt_ohio.gradle.plugins

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.internal.plugins.DslObject
import org.gradle.api.plugins.GroovyPlugin
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.GroovyRuntime
import org.gradle.api.tasks.GroovySourceSet
import org.gradle.api.tasks.SourceSet
import org.ssdt_ohio.gradle.tasks.UserDoc


class UserDocPlugin implements Plugin<Project> {


    private static final String USERDOC_TASK_NAME = 'userdoc'

    @Override
    void apply(Project project) {

        project.getPlugins().apply(GroovyPlugin.class)
        configureUserdoc(project)

    }

    private void configureUserdoc(final Project project) {
        UserDoc userDoc = project.getTasks().create(USERDOC_TASK_NAME, UserDoc.class);
        userDoc.setDescription("Generates UserDoc API documentation");
        userDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
        userDoc.windowTitle = project.name
        userDoc.docTitle = project.name

        JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class);
        SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
        userDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath()))


        GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class);
        println "srcdirs: " + groovySourceSet.getGroovy().getSrcDirs()
        userDoc.setSource(groovySourceSet.getGroovy());

        userDoc.setDestinationDir(new File(project.buildDir, "docs/userdoc"))

        userDoc.setGroovyClasspath(new GroovyRuntime(project).inferGroovyClasspath(project.configurations.compile))

    }

}