use of org.gradle.plugin.devel.tasks.GeneratePluginDescriptors in project gradle by gradle.
the class JavaGradlePluginPlugin method configureDescriptorGeneration.
private void configureDescriptorGeneration(final Project project, final GradlePluginDevelopmentExtension extension) {
final GeneratePluginDescriptors generatePluginDescriptors = project.getTasks().create(GENERATE_PLUGIN_DESCRIPTORS_TASK_NAME, GeneratePluginDescriptors.class);
generatePluginDescriptors.setGroup(PLUGIN_DEVELOPMENT_GROUP);
generatePluginDescriptors.setDescription(GENERATE_PLUGIN_DESCRIPTORS_TASK_DESCRIPTION);
generatePluginDescriptors.conventionMapping("declarations", new Callable<List<PluginDeclaration>>() {
@Override
public List<PluginDeclaration> call() {
return Lists.newArrayList(extension.getPlugins());
}
});
generatePluginDescriptors.conventionMapping("outputDirectory", new Callable<File>() {
@Override
public File call() {
return new File(project.getBuildDir(), generatePluginDescriptors.getName());
}
});
Copy processResources = (Copy) project.getTasks().getByName(PROCESS_RESOURCES_TASK);
CopySpec copyPluginDescriptors = processResources.getRootSpec().addChild();
copyPluginDescriptors.into("META-INF/gradle-plugins");
copyPluginDescriptors.from(new Callable<File>() {
@Override
public File call() {
return generatePluginDescriptors.getOutputDirectory();
}
});
processResources.dependsOn(generatePluginDescriptors);
}