Skip to content

Commit 1e0d950

Browse files
committed
Add product types for the created build tool plugin and command plugin packages
Most often these plugins are vended to other packages using products, so it makes sense to include this from the start.
1 parent 95784f7 commit 1e0d950

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Sources/Workspace/InitPackage.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@ public final class InitPackage {
216216
targets: ["\(pkgname)"]),
217217
]
218218
""")
219+
} else if packageType == .buildToolPlugin || packageType == .commandPlugin {
220+
pkgParams.append("""
221+
products: [
222+
// Products define the executables and libraries a package produces, making them visible to other packages.
223+
.plugin(
224+
name: "\(pkgname)",
225+
targets: ["\(pkgname)"]),
226+
]
227+
""")
219228
} else if packageType == .macro {
220229
pkgParams.append("""
221230
products: [

Tests/WorkspaceTests/InitTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class InitTests: XCTestCase {
168168
let manifest = path.appending("Package.swift")
169169
XCTAssertFileExists(manifest)
170170
let manifestContents: String = try localFileSystem.readFileContents(manifest)
171+
XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("targets: [\"MyCommandPlugin\"]")))
171172
XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("capability: .command(intent: .custom(verb")))
172173

173174
let source = path.appending("Plugins", "MyCommandPlugin", "plugin.swift")
@@ -196,6 +197,7 @@ class InitTests: XCTestCase {
196197
let manifest = path.appending("Package.swift")
197198
XCTAssertFileExists(manifest)
198199
let manifestContents: String = try localFileSystem.readFileContents(manifest)
200+
XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("targets: [\"MyBuildToolPlugin\"]")))
199201
XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("capability: .buildTool()")))
200202

201203
let source = path.appending("Plugins", "MyBuildToolPlugin", "plugin.swift")

0 commit comments

Comments
 (0)