diff --git a/Sources/Workspace/InitPackage.swift b/Sources/Workspace/InitPackage.swift index 2786b9b6a98..313b8869324 100644 --- a/Sources/Workspace/InitPackage.swift +++ b/Sources/Workspace/InitPackage.swift @@ -216,6 +216,15 @@ public final class InitPackage { targets: ["\(pkgname)"]), ] """) + } else if packageType == .buildToolPlugin || packageType == .commandPlugin { + pkgParams.append(""" + products: [ + // Products define the executables and libraries a package produces, making them visible to other packages. + .plugin( + name: "\(pkgname)", + targets: ["\(pkgname)"]), + ] + """) } else if packageType == .macro { pkgParams.append(""" products: [ diff --git a/Tests/WorkspaceTests/InitTests.swift b/Tests/WorkspaceTests/InitTests.swift index 38a445f5594..d462bbf7961 100644 --- a/Tests/WorkspaceTests/InitTests.swift +++ b/Tests/WorkspaceTests/InitTests.swift @@ -168,6 +168,7 @@ class InitTests: XCTestCase { let manifest = path.appending("Package.swift") XCTAssertFileExists(manifest) let manifestContents: String = try localFileSystem.readFileContents(manifest) + XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("targets: [\"MyCommandPlugin\"]"))) XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("capability: .command(intent: .custom(verb"))) let source = path.appending("Plugins", "MyCommandPlugin", "plugin.swift") @@ -196,6 +197,7 @@ class InitTests: XCTestCase { let manifest = path.appending("Package.swift") XCTAssertFileExists(manifest) let manifestContents: String = try localFileSystem.readFileContents(manifest) + XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("targets: [\"MyBuildToolPlugin\"]"))) XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("capability: .buildTool()"))) let source = path.appending("Plugins", "MyBuildToolPlugin", "plugin.swift")