Skip to content

Commit caab591

Browse files
committed
Adjust to SE-0303: Add path, exclude, and sources parameters to plugin targets.
1 parent b543c86 commit caab591

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

Sources/PackageDescription/Target.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ public final class Target {
274274
case .plugin:
275275
precondition(
276276
url == nil &&
277-
exclude.isEmpty &&
278-
sources == nil &&
279277
resources == nil &&
280278
publicHeadersPath == nil &&
281279
pkgConfig == nil &&
@@ -908,14 +906,17 @@ public final class Target {
908906
public static func plugin(
909907
name: String,
910908
capability: PluginCapability,
911-
dependencies: [Dependency] = []
909+
dependencies: [Dependency] = [],
910+
path: String? = nil,
911+
exclude: [String] = [],
912+
sources: [String]? = nil
912913
) -> Target {
913914
return Target(
914915
name: name,
915916
dependencies: dependencies,
916-
path: nil,
917-
exclude: [],
918-
sources: nil,
917+
path: path,
918+
exclude: exclude,
919+
sources: sources,
919920
publicHeadersPath: nil,
920921
type: .plugin,
921922
pluginCapability: capability)

Sources/PackageModel/Manifest/TargetDescription.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ public struct TargetDescription: Equatable, Codable {
174174
if pluginUsages != nil { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "pluginUsages") }
175175
case .plugin:
176176
if url != nil { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "url") }
177-
if !exclude.isEmpty { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "exclude") }
178-
if sources != nil { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "sources") }
179177
if !resources.isEmpty { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "resources") }
180178
if publicHeadersPath != nil { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "publicHeadersPath") }
181179
if pkgConfig != nil { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "pkgConfig") }

Tests/PackageLoadingTests/PD5_5LoadingTests.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,31 @@ class PackageDescription5_5LoadingTests: PackageDescriptionLoadingTests {
6060
XCTAssertEqual(manifest.targets[0].pluginCapability, .buildTool)
6161
}
6262
}
63+
64+
func testPluginPluginTargetCustomization() throws {
65+
let stream = BufferedOutputByteStream()
66+
stream <<< """
67+
import PackageDescription
68+
let package = Package(
69+
name: "Foo",
70+
targets: [
71+
.plugin(
72+
name: "Foo",
73+
capability: .buildTool(),
74+
path: "Sources/Foo",
75+
exclude: ["IAmOut.swift"],
76+
sources: ["CountMeIn.swift"]
77+
)
78+
]
79+
)
80+
"""
81+
82+
loadManifest(stream.bytes) { manifest in
83+
XCTAssertEqual(manifest.targets[0].type, .plugin)
84+
XCTAssertEqual(manifest.targets[0].pluginCapability, .buildTool)
85+
XCTAssertEqual(manifest.targets[0].path, "Sources/Foo")
86+
XCTAssertEqual(manifest.targets[0].exclude, ["IAmOut.swift"])
87+
XCTAssertEqual(manifest.targets[0].sources, ["CountMeIn.swift"])
88+
}
89+
}
6390
}

0 commit comments

Comments
 (0)