Mercurial > public > gradleplugins
view src/main/groovy/org/ssdt_ohio/gradle/plugins/UserDocPlugin.groovy @ 21:b14418c2ce40
set task output directory
author | smith@nwoca.org |
---|---|
date | Sun, 10 Jan 2016 16:43:54 +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)) } }