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));
}
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);
}
Aggregations