@@ -81,16 +81,24 @@ extension SwiftOpenAPIGeneratorPlugin: CommandPlugin {
81
81
log ( " - ✅ OpenAPI code generation for target ' \( target. name) ' successfully completed. " )
82
82
hadASuccessfulRun = true
83
83
} catch let error as PluginError {
84
- if targetNameArguments . isEmpty , case . fileErrors( let errors) = error,
84
+ if case . fileErrors( let errors) = error,
85
85
Set ( errors. map ( \. fileKind) ) == Set ( FileError . Kind. allCases) ,
86
86
errors. map ( \. issue) . allSatisfy ( { $0 == FileError . Issue. noFilesFound } )
87
87
{
88
- // The command plugin was run with no --target argument so its looping over all targets.
89
- // If a target does not have any of the required files, this should only be considered an error
90
- // if the plugin is being explicitly run on a target, either using the build plugin, or using the
91
- // command plugin with a --target argument.
92
- log ( " - Skipping because target isn't configured for OpenAPI code generation. " )
93
- continue
88
+ // The error is that neither of the required files are present for code generation for this target.
89
+ // This should only be considered an error if this target was explicitly provided as a target for
90
+ // code generation with --target.
91
+ // We may get this error for other targets if:
92
+ //
93
+ // 1. The command plugin was run with no --target arguments, in which case the plugin loops over
94
+ // all targets; or
95
+ // 2. This target is a dependency of a target that was requested using --target.
96
+ //
97
+ // In either of these cases, we should not consider this an error and skip the target.
98
+ if !targetNameArguments. contains ( target. name) {
99
+ log ( " - Skipping because target isn't configured for OpenAPI code generation. " )
100
+ continue
101
+ }
94
102
}
95
103
96
104
if error. isMisconfigurationError {
0 commit comments