Mercurial > public > gradleplugins
view src/main/groovy/org/ssdt_ohio/gradle/plugins/UserDocPlugin.groovy @ 17:3741247de37a
USASR-1307: add helper to resolve template classpath problem
author | smith@nwoca.org |
---|---|
date | Thu, 01 Jan 2015 00:01:02 +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)) } }