Search in sources :

Example 1 with GradlePluginDevelopmentExtension

use of org.gradle.plugin.devel.GradlePluginDevelopmentExtension in project gradle by gradle.

the class PrecompiledGroovyPluginsPlugin method exposeScriptsAsPlugins.

private void exposeScriptsAsPlugins(Project project) {
    GradlePluginDevelopmentExtension pluginExtension = project.getExtensions().getByType(GradlePluginDevelopmentExtension.class);
    SourceSet pluginSourceSet = pluginExtension.getPluginSourceSet();
    FileTree scriptPluginFiles = pluginSourceSet.getAllSource().matching(PrecompiledGroovyScript::filterPluginFiles);
    List<PrecompiledGroovyScript> scriptPlugins = scriptPluginFiles.getFiles().stream().map(file -> new PrecompiledGroovyScript(file, getTextFileResourceLoader())).peek(scriptPlugin -> validateScriptPlugin(project, scriptPlugin)).collect(Collectors.toList());
    declarePluginMetadata(pluginExtension, scriptPlugins);
    DirectoryProperty buildDir = project.getLayout().getBuildDirectory();
    TaskContainer tasks = project.getTasks();
    TaskProvider<ExtractPluginRequestsTask> extractPluginRequests = tasks.register("extractPluginRequests", ExtractPluginRequestsTask.class, task -> {
        task.getScriptPlugins().convention(scriptPlugins);
        task.getScriptFiles().from(scriptPluginFiles.getFiles());
        task.getExtractedPluginRequestsClassesDirectory().convention(buildDir.dir("groovy-dsl-plugins/output/plugin-requests"));
        task.getExtractedPluginRequestsClassesStagingDirectory().convention(buildDir.dir("groovy-dsl-plugins/output/plugin-requests-staging"));
    });
    TaskProvider<GeneratePluginAdaptersTask> generatePluginAdapters = tasks.register("generatePluginAdapters", GeneratePluginAdaptersTask.class, task -> {
        task.getScriptPlugins().convention(scriptPlugins);
        task.getExtractedPluginRequestsClassesDirectory().convention(extractPluginRequests.flatMap(ExtractPluginRequestsTask::getExtractedPluginRequestsClassesDirectory));
        task.getPluginAdapterSourcesOutputDirectory().convention(buildDir.dir("groovy-dsl-plugins/output/adapter-src"));
    });
    TaskProvider<CompileGroovyScriptPluginsTask> precompilePlugins = tasks.register("compileGroovyPlugins", CompileGroovyScriptPluginsTask.class, task -> {
        task.getScriptPlugins().convention(scriptPlugins);
        task.getScriptFiles().from(scriptPluginFiles.getFiles());
        task.getPrecompiledGroovyScriptsOutputDirectory().convention(buildDir.dir("groovy-dsl-plugins/output/plugin-classes"));
        SourceDirectorySet javaSource = pluginSourceSet.getJava();
        SourceDirectorySet groovySource = pluginSourceSet.getExtensions().getByType(GroovySourceDirectorySet.class);
        task.getClasspath().from(pluginSourceSet.getCompileClasspath(), javaSource.getClassesDirectory(), groovySource.getClassesDirectory());
    });
    pluginSourceSet.getJava().srcDir(generatePluginAdapters.flatMap(GeneratePluginAdaptersTask::getPluginAdapterSourcesOutputDirectory));
    pluginSourceSet.getOutput().dir(precompilePlugins.flatMap(CompileGroovyScriptPluginsTask::getPrecompiledGroovyScriptsOutputDirectory));
    pluginSourceSet.getOutput().dir(extractPluginRequests.flatMap(ExtractPluginRequestsTask::getExtractedPluginRequestsClassesStagingDirectory));
}
Also used : CORE_PLUGIN_PREFIX(org.gradle.api.internal.plugins.DefaultPluginManager.CORE_PLUGIN_PREFIX) Project(org.gradle.api.Project) JavaGradlePluginPlugin(org.gradle.plugin.devel.plugins.JavaGradlePluginPlugin) SourceDirectorySet(org.gradle.api.file.SourceDirectorySet) CORE_PLUGIN_NAMESPACE(org.gradle.api.internal.plugins.DefaultPluginManager.CORE_PLUGIN_NAMESPACE) TextFileResourceLoader(org.gradle.internal.resource.TextFileResourceLoader) GradlePluginDevelopmentExtension(org.gradle.plugin.devel.GradlePluginDevelopmentExtension) Collectors(java.util.stream.Collectors) SourceSet(org.gradle.api.tasks.SourceSet) Inject(javax.inject.Inject) List(java.util.List) GroovyBasePlugin(org.gradle.api.plugins.GroovyBasePlugin) GroovySourceDirectorySet(org.gradle.api.tasks.GroovySourceDirectorySet) TaskContainer(org.gradle.api.tasks.TaskContainer) GradleException(org.gradle.api.GradleException) FileTree(org.gradle.api.file.FileTree) TaskProvider(org.gradle.api.tasks.TaskProvider) DirectoryProperty(org.gradle.api.file.DirectoryProperty) Documentation(org.gradle.internal.deprecation.Documentation) Plugin(org.gradle.api.Plugin) SourceSet(org.gradle.api.tasks.SourceSet) DirectoryProperty(org.gradle.api.file.DirectoryProperty) TaskContainer(org.gradle.api.tasks.TaskContainer) GradlePluginDevelopmentExtension(org.gradle.plugin.devel.GradlePluginDevelopmentExtension) FileTree(org.gradle.api.file.FileTree) SourceDirectorySet(org.gradle.api.file.SourceDirectorySet) GroovySourceDirectorySet(org.gradle.api.tasks.GroovySourceDirectorySet)

Example 2 with GradlePluginDevelopmentExtension

use of org.gradle.plugin.devel.GradlePluginDevelopmentExtension in project gradle by gradle.

the class JavaGradlePluginPlugin method apply.

@Override
public void apply(Project project) {
    project.getPluginManager().apply(JavaLibraryPlugin.class);
    applyDependencies(project);
    GradlePluginDevelopmentExtension extension = createExtension(project);
    configureJarTask(project, extension);
    configureTestKit(project, extension);
    configurePublishing(project);
    registerPlugins(project, extension);
    configureDescriptorGeneration(project, extension);
    validatePluginDeclarations(project, extension);
    configurePluginValidations(project, extension);
}
Also used : GradlePluginDevelopmentExtension(org.gradle.plugin.devel.GradlePluginDevelopmentExtension)

Aggregations

GradlePluginDevelopmentExtension (org.gradle.plugin.devel.GradlePluginDevelopmentExtension)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 GradleException (org.gradle.api.GradleException)1 Plugin (org.gradle.api.Plugin)1 Project (org.gradle.api.Project)1 DirectoryProperty (org.gradle.api.file.DirectoryProperty)1 FileTree (org.gradle.api.file.FileTree)1 SourceDirectorySet (org.gradle.api.file.SourceDirectorySet)1 CORE_PLUGIN_NAMESPACE (org.gradle.api.internal.plugins.DefaultPluginManager.CORE_PLUGIN_NAMESPACE)1 CORE_PLUGIN_PREFIX (org.gradle.api.internal.plugins.DefaultPluginManager.CORE_PLUGIN_PREFIX)1 GroovyBasePlugin (org.gradle.api.plugins.GroovyBasePlugin)1 GroovySourceDirectorySet (org.gradle.api.tasks.GroovySourceDirectorySet)1 SourceSet (org.gradle.api.tasks.SourceSet)1 TaskContainer (org.gradle.api.tasks.TaskContainer)1 TaskProvider (org.gradle.api.tasks.TaskProvider)1 Documentation (org.gradle.internal.deprecation.Documentation)1 TextFileResourceLoader (org.gradle.internal.resource.TextFileResourceLoader)1 JavaGradlePluginPlugin (org.gradle.plugin.devel.plugins.JavaGradlePluginPlugin)1