I was trying out the new BuildToolPlugin and was wondering if its possible for a plugin to access outputs generated from the plugin for a different target.
The plugin was meant to support a modularized codebase with many modules.
In the setup there would be one "top-level" module (the App) and many feature-modules.
The top-level module
For that purpose i wanted to create two plugins:
one "producer" plugin that inspects source files and generates a single file
one "consumer" plugin that aggregates all the files produced for modules that
the "consumer" plugin would be applied to the top-level module.
Is it somehow possible to get access to the generated files?
I don't think this is supported today, but that definitely seems like something that should be supported. If multiple plugins are applied to a single target then the outputs of the first are supposed to be visible to the second, but not across targets. But there's no reason that shouldn't work (at least for regular build tool plugin commands where you declare what the outputs will be).
In this API, would you want/need to be able to distinguish the generated outputs from the actual sources, or should they in your view be treated the same, i.e. just appear in the
sourceFiles property of the
SourceModuleTarget in the plugin?
In my case i would not be generating
My example is a DependencyInjection plugin.
The idea is to analyse each SourceFile using
SwiftSyntax and extract a dependency-graph.
There is special Syntax to either "provide" or "consume" a certain dependency.
The plugin would pick that up and generate a single
dependency_graph.json file for each target.
And then at the top-level (In my case a iOS app target) i would like to inspect all the
I want to verify that the graph is actually satisfiable (which in my specific case can only be done on the top-level)
dependency_graph.json is generated in
A approach that, i think, would enable my usecase, would be if
DependencyTargetInfo actually exposed the path to that targets
Another thing that would be useful if
DependencyTargetInfo also lists which plugins are applied to it.
I would use this as a way to tell if i can expect the
dependency_graph.json file to be generated for that target.
Any Feedback is welcome
Thanks for the detailed description of what your plugin wants to do. I think you're right that this would involve extending
DependencyTargetInfo to include the information from the other plugins, and that seems like a good direction to go. I don't know of any workarounds using the current API but I'll see if I can think of a way around it short of that.