Skip to content

Commit cb4ba47

Browse files
authored
Fixup deprecation warning in PluginContext.Tool initializer (#8422)
Setting `path` directly in the initializer of PluginContext.Tool triggers a deprecation warning, because `path` is marked as deprecated. Set a private field, and have the deprecated public field use a getter to access it. This resolves the warning.
1 parent 24bedf6 commit cb4ba47

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/PackagePlugin/Context.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,20 @@ public struct PluginContext {
102102

103103
/// Full path of the built or provided tool in the file system.
104104
@available(_PackageDescription, deprecated: 6.0, renamed: "url")
105-
public let path: Path
105+
public var path: Path {
106+
get { _path }
107+
}
106108

107109
/// Full path of the built or provided tool in the file system.
108110
@available(_PackageDescription, introduced: 6.0)
109111
public let url: URL
110112

113+
private let _path: Path
114+
111115
@_spi(PackagePluginInternal) public init(name: String, path: Path, url: URL) {
112116
self.name = name
113-
self.path = path
114117
self.url = url
118+
self._path = path
115119
}
116120
}
117121
}

0 commit comments

Comments
 (0)