Search in sources :

Example 1 with GeneratePluginDescriptors

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);
}
Also used : CopySpec(org.gradle.api.file.CopySpec) Copy(org.gradle.api.tasks.Copy) GeneratePluginDescriptors(org.gradle.plugin.devel.tasks.GeneratePluginDescriptors) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CopySpec (org.gradle.api.file.CopySpec)1 Copy (org.gradle.api.tasks.Copy)1 GeneratePluginDescriptors (org.gradle.plugin.devel.tasks.GeneratePluginDescriptors)1