Skip to content

Commit 22b65b2

Browse files
committed
Implement PR review feedback
1 parent bcd3c3b commit 22b65b2

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

Sources/Commands/SwiftPackageTool.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ extension SwiftPackageTool {
942942
// Configure the plugin invocation inputs.
943943

944944
// The `plugins` directory is inside the workspace's main data directory, and contains all temporary files related to all plugins in the workspace.
945-
let pluginsDir = try swiftTool.getActiveWorkspace().location.pluginDataDirectory
945+
let pluginsDir = try swiftTool.getActiveWorkspace().location.pluginWorkingDirectory
946946

947947
// The `cache` directory is in the plugins directory and is where the plugin script runner caches compiled plugin binaries and any other derived information.
948948
let cacheDir = pluginsDir.appending(component: "cache")
@@ -953,7 +953,7 @@ extension SwiftPackageTool {
953953

954954
// Build the map of tools that are available to the plugin. This should include the tools in the executables in the toolchain, as well as any executables the plugin depends on (built executables as well as prebuilt binaries).
955955
// FIXME: At the moment we just pass the built products directory for the host. We will need to extend this with a map of the names of tools available to each plugin. In particular this would not work with any binary targets.
956-
let dataDir = try swiftTool.getActiveWorkspace().location.pluginDataDirectory
956+
let dataDir = try swiftTool.getActiveWorkspace().location.pluginWorkingDirectory
957957
let builtToolsDir = dataDir.appending(components: "plugin-tools")
958958

959959
// Create the cache directory, if needed.

Sources/Commands/SwiftTool.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ public class SwiftTool {
739739
// The `plugins` directory is inside the workspace's main data directory, and contains all temporary
740740
// files related to all plugins in the workspace.
741741
let buildEnvironment = try buildParameters().buildEnvironment
742-
let pluginsDir = try self.getActiveWorkspace().location.pluginDataDirectory
742+
let pluginsDir = try self.getActiveWorkspace().location.pluginWorkingDirectory
743743

744744
// The `cache` directory is in the plugins directory and is where the plugin script runner caches
745745
// compiled plugin binaries and any other derived information.

Sources/SPMBuildCore/PluginInvocation.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ extension PluginTarget {
7474
pluginAction: action)
7575

7676
// Serialize the PluginEvaluationInput to JSON.
77-
let encoder = JSONEncoder()
78-
encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes]
79-
let inputJSON = try encoder.encode(inputStruct)
77+
let inputJSON = try JSONEncoder.makeWithDefaults().encode(inputStruct)
8078

8179
// Call the plugin script runner to actually invoke the plugin.
8280
// TODO: This should be asynchronous.
@@ -92,8 +90,7 @@ extension PluginTarget {
9290
// Deserialize the JSON to an PluginScriptRunnerOutput.
9391
let outputStruct: PluginScriptRunnerOutput
9492
do {
95-
let decoder = JSONDecoder()
96-
outputStruct = try decoder.decode(PluginScriptRunnerOutput.self, from: outputJSON)
93+
outputStruct = try JSONDecoder.makeWithDefaults().decode(PluginScriptRunnerOutput.self, from: outputJSON)
9794
}
9895
catch {
9996
throw PluginEvaluationError.decodingPluginOutputFailed(json: outputJSON, underlyingError: error)
@@ -155,7 +152,6 @@ extension PluginTarget {
155152
}
156153
}
157154

158-
159155
extension PackageGraph {
160156

161157
/// Traverses the graph of reachable targets in a package graph, and applies plugins to targets as needed. Each

Sources/Workspace/WorkspaceConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ extension Workspace {
7878
}
7979

8080
// Path to temporary files related to running plugins in the workspace
81-
public var pluginDataDirectory: AbsolutePath {
81+
public var pluginWorkingDirectory: AbsolutePath {
8282
self.workingDirectory.appending(component: "plugins")
8383
}
8484

0 commit comments

Comments
 (0)