@@ -1170,32 +1170,20 @@ final class PluginDelegate: PluginInvocationDelegate {
1170
1170
1171
1171
// Create a build operation. We have to disable the cache in order to get a build plan created.
1172
1172
let outputStream = BufferedOutputByteStream ( )
1173
- let buildOperation = BuildOperation (
1174
- buildParameters : buildParameters ,
1173
+ let buildOperation = try self . swiftTool . createBuildOperation (
1174
+ explicitProduct : explicitProduct ,
1175
1175
cacheBuildManifest: false ,
1176
- packageGraphLoader: { try self . swiftTool. loadPackageGraph ( explicitProduct: explicitProduct) } ,
1177
- pluginScriptRunner: try self . swiftTool. getPluginScriptRunner ( ) ,
1178
- pluginWorkDirectory: try self . swiftTool. getActiveWorkspace ( ) . location. pluginWorkingDirectory,
1179
- outputStream: outputStream,
1180
- logLevel: logLevel,
1181
- fileSystem: swiftTool. fileSystem,
1182
- observabilityScope: self . swiftTool. observabilityScope
1176
+ customBuildParameters: buildParameters,
1177
+ customOutputStream: outputStream,
1178
+ customLogLevel: logLevel
1183
1179
)
1184
1180
1185
- // Save the instance so it can be canceled from the interrupt handler.
1186
- self . swiftTool. buildSystemRef. buildSystem = buildOperation
1187
-
1188
- // Get or create the build description and plan the build.
1189
- let _ = try buildOperation. getBuildDescription ( )
1190
- let buildPlan = buildOperation. buildPlan!
1191
-
1192
1181
// Run the build. This doesn't return until the build is complete.
1193
- var success = true
1194
- do {
1195
- try buildOperation. build ( subset: buildSubset)
1196
- }
1197
- catch {
1198
- success = false
1182
+ let success = buildOperation. buildIgnoringError ( subset: buildSubset)
1183
+
1184
+ // Get the build plan used
1185
+ guard let buildPlan = buildOperation. buildPlan else {
1186
+ throw InternalError ( " invalid state, buildPlan is undefined " )
1199
1187
}
1200
1188
1201
1189
// Create and return the build result record based on what the delegate collected and what's in the build plan.
@@ -1942,3 +1930,14 @@ private extension Basics.Diagnostic {
1942
1930
. error( " missing required argument \( argument) " )
1943
1931
}
1944
1932
}
1933
+
1934
+ extension BuildOperation {
1935
+ fileprivate func buildIgnoringError( subset: BuildSubset ) -> Bool {
1936
+ do {
1937
+ try self . build ( subset: subset)
1938
+ return true
1939
+ } catch {
1940
+ return false
1941
+ }
1942
+ }
1943
+ }
0 commit comments