Skip to content

Commit e0aadff

Browse files
authored
Mark command plugins as 5.6 instead of 999.0 now that SE-0332 has been accepted (#3969)
* Mark command plugins as 5.6 instead of 999.0 now that SE-0332 has been accepted, and remove the feature flag that controls it. * Add reference to SE-0332 to CHANGELOG.md. * Update the other proposal links to use `main` branch name.
1 parent 42903af commit e0aadff

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

CHANGELOG.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ Note: This is in reverse chronological order, so newer entries are added to the
22

33
Swift 5.6
44
-----------
5+
* [SE-0332]
6+
7+
Package plugins of the type `command` can now be declared in packages that specify a tools version of 5.6 or later, and can be invoked using the `swift package` subcommand.
8+
59
* [#3649]
610

711
Semantic version dependencies can now be resolved against Git tag names that contain only major and minor version identifiers. A tag with the form `X.Y` will be treated as `X.Y.0`. This improves compatibility with existing repositories.
@@ -153,11 +157,12 @@ Swift 3.0
153157

154158
* The `Package` initializer now requires the `name:` parameter.
155159

156-
[SE-0129]: https://github.com/apple/swift-evolution/blob/master/proposals/0129-package-manager-test-naming-conventions.md
157-
[SE-0135]: https://github.com/apple/swift-evolution/blob/master/proposals/0135-package-manager-support-for-differentiating-packages-by-swift-version.md
158-
[SE-0201]: https://github.com/apple/swift-evolution/blob/master/proposals/0201-package-manager-local-dependencies.md
159-
[SE-0208]: https://github.com/apple/swift-evolution/blob/master/proposals/0208-package-manager-system-library-targets.md
160-
[SE-0209]: https://github.com/apple/swift-evolution/blob/master/proposals/0209-package-manager-swift-lang-version-update.md
160+
[SE-0129]: https://github.com/apple/swift-evolution/blob/main/proposals/0129-package-manager-test-naming-conventions.md
161+
[SE-0135]: https://github.com/apple/swift-evolution/blob/main/proposals/0135-package-manager-support-for-differentiating-packages-by-swift-version.md
162+
[SE-0201]: https://github.com/apple/swift-evolution/blob/main/proposals/0201-package-manager-local-dependencies.md
163+
[SE-0208]: https://github.com/apple/swift-evolution/blob/main/proposals/0208-package-manager-system-library-targets.md
164+
[SE-0209]: https://github.com/apple/swift-evolution/blob/main/proposals/0209-package-manager-swift-lang-version-update.md
165+
[SE-0332]: https://github.com/apple/swift-evolution/blob/main/proposals/0332-swiftpm-command-plugins.md
161166

162167
[SR-5918]: https://bugs.swift.org/browse/SR-5918
163168
[SR-6978]: https://bugs.swift.org/browse/SR-6978

Sources/Commands/SwiftPackageTool.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
4+
Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -60,9 +60,9 @@ public struct SwiftPackageTool: ParsableCommand {
6060
ComputeChecksum.self,
6161
ArchiveSource.self,
6262
CompletionTool.self,
63+
PluginCommand.self,
6364
]
64-
+ (ProcessInfo.processInfo.environment["SWIFTPM_ENABLE_SNIPPETS"] == "1" ? [Learn.self] : [])
65-
+ (ProcessInfo.processInfo.environment["SWIFTPM_ENABLE_COMMAND_PLUGINS"] == "1" ? [PluginCommand.self] : []),
65+
+ (ProcessInfo.processInfo.environment["SWIFTPM_ENABLE_SNIPPETS"] == "1" ? [Learn.self] : []),
6666
helpNames: [.short, .long, .customLong("help", withSingleDash: true)])
6767

6868
@OptionGroup()

Sources/PackageDescription/Target.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public final class Target {
131131
/// this enum will be extended as new plugin capabilities are added.
132132
public enum PluginCapability {
133133
case _buildTool
134-
@available(_PackageDescription, introduced: 999.0)
134+
@available(_PackageDescription, introduced: 5.6)
135135
case _command(intent: PluginCommandIntent, permissions: [PluginPermission])
136136
}
137137

@@ -1016,7 +1016,7 @@ extension Target.PluginCapability {
10161016
/// Specifies that the plugin provides a user command capability. It will
10171017
/// be available to invoke manually on one or more targets in a package.
10181018
/// The package can specify the verb that is used to invoke the command.
1019-
@available(_PackageDescription, introduced: 999.0)
1019+
@available(_PackageDescription, introduced: 5.6)
10201020
/// Plugins that specify a `command` capability define commands that can be run
10211021
/// using the SwiftPM CLI (`swift package <verb>`), or in an IDE that supports
10221022
/// Swift Packages.
@@ -1034,14 +1034,14 @@ extension Target.PluginCapability {
10341034
}
10351035
}
10361036

1037-
@available(_PackageDescription, introduced: 999.0)
1037+
@available(_PackageDescription, introduced: 5.6)
10381038
public enum PluginCommandIntent {
10391039
case _documentationGeneration
10401040
case _sourceCodeFormatting
10411041
case _custom(verb: String, description: String)
10421042
}
10431043

1044-
@available(_PackageDescription, introduced: 999.0)
1044+
@available(_PackageDescription, introduced: 5.6)
10451045
public extension PluginCommandIntent {
10461046
/// The intent of the command is to generate documentation, either by parsing the
10471047
/// package contents directly or by using the build system support for generating
@@ -1063,12 +1063,12 @@ public extension PluginCommandIntent {
10631063
}
10641064
}
10651065

1066-
@available(_PackageDescription, introduced: 999.0)
1066+
@available(_PackageDescription, introduced: 5.6)
10671067
public enum PluginPermission {
10681068
case _writeToPackageDirectory(reason: String)
10691069
}
10701070

1071-
@available(_PackageDescription, introduced: 999.0)
1071+
@available(_PackageDescription, introduced: 5.6)
10721072
public extension PluginPermission {
10731073
/// The command plugin wants permission to modify the files under the package
10741074
/// directory. The `reason` string is shown to the user at the time of request

Tests/CommandsTests/PackageToolTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ final class PackageToolTests: CommandsTestCase {
10461046
let packageDir = tmpPath.appending(components: "MyPackage")
10471047
try localFileSystem.writeFileContents(packageDir.appending(component: "Package.swift")) {
10481048
$0 <<< """
1049-
// swift-tools-version: 999.0
1049+
// swift-tools-version: 5.5
10501050
import PackageDescription
10511051
let package = Package(
10521052
name: "MyPackage",
@@ -1191,7 +1191,7 @@ final class PackageToolTests: CommandsTestCase {
11911191
let packageDir = tmpPath.appending(components: "MyPackage")
11921192
try localFileSystem.writeFileContents(packageDir.appending(components: "Package.swift")) {
11931193
$0 <<< """
1194-
// swift-tools-version: 999.0
1194+
// swift-tools-version: 5.6
11951195
import PackageDescription
11961196
let package = Package(
11971197
name: "MyPackage",
@@ -1335,14 +1335,14 @@ final class PackageToolTests: CommandsTestCase {
13351335

13361336
// Invoke it, and check the results.
13371337
do {
1338-
let result = try SwiftPMProduct.SwiftPackage.executeProcess(["plugin", "mycmd"], packagePath: packageDir, env: ["SWIFTPM_ENABLE_COMMAND_PLUGINS": "1"])
1338+
let result = try SwiftPMProduct.SwiftPackage.executeProcess(["plugin", "mycmd"], packagePath: packageDir)
13391339
XCTAssertEqual(result.exitStatus, .terminated(code: 0))
13401340
XCTAssert(try result.utf8Output().contains("This is MyCommandPlugin."))
13411341
}
13421342

13431343
// Testing listing the available command plugins.
13441344
do {
1345-
let result = try SwiftPMProduct.SwiftPackage.executeProcess(["plugin", "--list"], packagePath: packageDir, env: ["SWIFTPM_ENABLE_COMMAND_PLUGINS": "1"])
1345+
let result = try SwiftPMProduct.SwiftPackage.executeProcess(["plugin", "--list"], packagePath: packageDir)
13461346
XCTAssertEqual(result.exitStatus, .terminated(code: 0))
13471347
XCTAssert(try result.utf8Output().contains("‘mycmd’ (plugin ‘MyPlugin’ in package ‘MyPackage’)"))
13481348
}

Tests/FunctionalTests/PluginTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class PluginTests: XCTestCase {
193193
let packageDir = tmpPath.appending(components: "MyPackage")
194194
try localFileSystem.writeFileContents(packageDir.appending(component: "Package.swift")) {
195195
$0 <<< """
196-
// swift-tools-version: 999.0
196+
// swift-tools-version: 5.6
197197
import PackageDescription
198198
let package = Package(
199199
name: "MyPackage",

0 commit comments

Comments
 (0)